V2 Rest API Add Contact 400 Bad Request

Does any one have an example of adding a contact via the V2 Rest API? I am getting a 400 Bad Request Error. The documentation says one item is required in email_addresses or phone_numbers and countryPcode is required if region is specified. I am only adding an email address and nothing else and continue to get this error no matter what I try.

Good afternoon Jeff!

Can you provide the URL and a sample of the payload (removing sensitive data)?

Hi Tom,

I am sending a post to: https://api.infusionsoft.com/crm/rest/v2/contacts

This is the content I am sending

{"email_addresses":[{"email":"email@example.com","field":"EMAIL1","opt_in_reason":"Permission box was checked.","is_opt_in":true,"email_opt_status":"SINGLE_OPT_IN"}]}

I have been trying to get the minimal working and have more fields to add, just trying to get a basic contact added first.

Per the Create a Contact documentation, you should only have three properties on the email_address sub-object: email, field and opt_in_reason. The other two properties you have there, is_opt_in and email_opt_status are returned from the server in response to queries as computed values.

Hi Tom,

Thanks for the information. I am still getting a 400 Bad Request with the following payload. Any ideas?

{“email_addresses”:[{“email":"email@example.com”,“field”:“EMAIL1”,“opt_in_reason”:“Permission box was checked.”}]}

Same with this payload:
{“email_addresses”:[{“email":"email@example.com”,“field”:“EMAIL_FIELD_UNSPECIFIED”,“opt_in_reason”:“Processed Order”}]}

I would suggest checking your payload to make sure you don’t have any strange characters in there (such as backquotes), as it is apparently working fine.

Are there any c# code examples anywhere? The only c# examples I can find are over 10 years old and using an API that has been marked as deprecated for over 5 years.

We do not use .NET in-house, so I am unfortunately unable to assist you with that.

Can you test to see if “EMAIL_FIELD_UNSPECIFIED” works for you? I am not sure what changed, but using EMAIL1 works and EMAIL_FIELD_UNSPECIFIED does not.