Create or Update contact issue with addresses

On API it’s clearly saying that, country_code is required if region is specified

In our api request we’re not sending region just line1 or line2 for addresses like follows

[addresses] => Array
    (
        [0] => Array
            (
                [line1] => shah ali bag, 243 lane, dhaka
                [field] => BILLING
            )

        [1] => Array
            (
                [line1] => shah ali bag, 243 lane, dhaka
                [field] => SHIPPING
            )

    )

But the response is:

Client error: `PUT https://api.infusionsoft.com/crm/rest/v1/contacts/?access_token=yzkdqt5yuq6a6wfk5t7kpc99` resulted in a `400 Bad Request` response:

{“message”:“BILLING Country Code is invalid, SHIPPING Country Code is invalid”}

Can you please advise what is going on? Also on Zapier we can see anything can be added to any field but through the API you provided we cannot send, it’s throwing error e.g for website

Hi @Yazamo_Developers, we are actively looking into this and I believe that it is a bug that was recently introduced. It should not return a 400 with an error message if you don’t provide a value for country code.

okay, please let us know, also I can add anything from Zapier to the contact field but from our api we cannot save anything to any field, it returns the validation error. How can we do it like Zapier?

If you set the country_code field to a valid ISO code value it will allow you to save the contact without error.

I just don’t want to send any country and region, then it should not give us any error right? Can you let me know what is the best way to map anything into infusionsoft contact without having these unwanted error like Zapier Integration, because on Zapier we can save anything to any field, for phone->type if we send a string that doesn’t match with the types on infusionsoft it gives us error, but on Zapier it takes any string and show on infusionsoft contact.

Please advice, what should we do?

It sounds like you are using the REST API which does enforce validation on certain fields. I believe that Zapier uses the XML-RPC API which enforces very few validation rules and will allow you to save any value for phone type like you mentioned.

We are actively working to transition developers over to using REST so I would recommend against developing new integrations using XML-RPC.

Yes we’re using REST API, and we want it to be like Zapier, then should we change our method to XML-RPC or we should stay with REST API because it looks like, you guys are developing the REST api still?

The phone type drop down can be customized if you go into the UI and then hover over the Infusionsoft logo > CRM > Settings > Contact & Company Settings > General > Phone Types. This is the list of values that the REST API validates against.

However, you could use the XML-RPC API if you need to provide arbitrary values for the phone type field. We are no longer actively developing the XML-RPC API and will be sun setting it at some point in the future.

This issue is still persisting for Zapier. There isn’t an option to put in a billing or shipping region, so how do we fix this?

I’m getting the error The app returned “BILLING Region is invalid, SHIPPING Region is invalid”.

They will need to update the integration it sounds like. That error is returned when you supply the region field in the request. However if their integration is not providing the ability for you to set a region, then the address fields should not be sent over in the API request so as to avoid any address validation errors.

I still get this error (Sept 2022)!

Hi all, I am going to say a few things about what is discussed here.

Zapier

Zapier has been around for several years now and its initial integration with Infusionsoft was done via the XML-RPC API. Zapier has been designed to be simple to use, but it is not suitable for more complex integrations.

From what it is being reported here, it seems that they have jumped to use the REST API v1 now.

Keap REST API

Quotes from Nicholas in August 2018.

We are actively working to transition developers over to using REST so I would recommend against developing new integrations using XML-RPC.

However, you could use the XML-RPC API if you need to provide arbitrary values for the phone type field. We are no longer actively developing the XML-RPC API and will be sun setting it at some point in the future.

Those two statements are no longer valid. Whoever designed REST API v1 completely ignored the capabilities of what the XML-RPC API offered, or they assumed developers would be happy with the REST API functions provided. Unfortunately over the years when developers ask for something specific to be done in the REST API, some of the answers have been to revert back to the XML-RPC because it provides the functionality.

Sunsetting of the XML-RPC is no longer going to be happening for a long time. The issue is that REST v1 is no longer actively being developed either, because REST v2 is being concentrated on now. So now there is integrations with XML-RPC, or REST v1 with XML-RPC, or REST v2 with XML-RPC, and other combinations as well.

The REST API could have been successful if it provided full backwards capabilities, but it fell short.

Suggested Solution

One solution that comes to mind to get around this issue would be to Country mappings between the different processes. I have done that in the past whereby I had to map two different country lists between Infusionsoft and another integration.

If you are allowing free text to be entered for the Country Name then that is going to be a problem. People could enter a variety of different ways to spell a country, eg: Full Name, Short Name, Abbreviated Name. The other issue of free text is that if someone makes a spelling mistake, the software would have to deal with it, or default it to a particular country. I recommend that you have a Country drop down list.

In regards to Zapier, they are not going to be doing anything with the country either. They will just pass through whatever is sent to it. They are no way going to be creating country mappings, because there is going to be 1000s of combinations.

I main reason for why Keap is putting this restriction in is for data accuracy, and maybe for the Pro / Max products as well. The XML-RPC API allows any text, but it should really match the Country list Keap has got. But there probably be other integrations that could also be applying strict country names or codes as well.

You can try speaking to Zapier about the issue. But you will have to rethink who things are integrated to get this to work.