cancel
Showing results for 
Search instead for 
Did you mean: 
Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.

Can't Do AddContact

SOLVED
Advisor

Can't Do AddContact

I'm getting message http.status.bad_request:Bad request. upon attempting and AddContact. I'm using the C# wrapper for the version 2 APIs. The json string that is being posted is:

 

 

{"addresses":[{"country_code":"BR","postal_code":"01008-000"}],"custom_fields":[],"email_addresses":[{"email_address":"blissbunny108@gmail.com"}],"first_name":"Amar","last_name":"a Deus","lists":[{"contact_count":102,"id":"1084848296","name":"Self-Realization Fellowship Mailing List","status":"ACTIVE"}],"notes":[]}

 

Can you explain why I'm getting this error?

7 REPLIES 7
Solution Provider

Re: Can't Do AddContact

I've been getting the same error using the C# wrapper since 7/7.

Advisor

Re: Can't Do AddContact

I have more information. I started testing with the sample program provided when you download the API wrapper. First I attempted to add a contact just specifying the email address and the list to which that contact should belong. In that case, the AddContact worked fine. But as soon as I specified a country it failed just as before. Note, in the sample program if  you specify United States or Canada, the program doesn't pass a country. So I specified Australia which caused the sample program to include "AU" as the country. As stated, this failed with http.status.bad_request:Bad request

Advisor

Re: Can't Do AddContact

One additional finding is that in our production code it wasn't sufficient to comment out the country. In order to make AddContact work I had to supress the creation of an Addresses object altogether.

Honored Contributor

Re: Can't Do AddContact

Hello,

 

Thank you for reaching out to us about this behavior. After some investigation, we found that the error is that these contacts have a physical address that does not have the address type set. This is correctly labeled as a 400 Bad Request, but the error message is not currently describing the problem. We're working with the rest of the team here to get this issue prioritized and lined up for a fix soon.

 

In the meantime, you can easily work around this by adding an address type to the contacts that you create. You can do this by assigning the AddressType property of an Address object in the following manner:

addressObject.AddressType = Address.AddressType.PERSONAL
OR
addressObject.AddressType = Address.AddressType.BUSINESS

Once you've assigned the address type for any physical addresses associated with a contact, that should resolve the problem. If you're continuing to see strange behavior, please let me know!

 

Sincerely,

Elijah G.
API Support Engineer
Advisor

Re: Can't Do AddContact

Thank you Elijah. We set all address objects to have a type of Personal. In reality we don't have this information captured on our database. But we will do whatever it takes to make this work.

 

FYI intellisense gave me three options for address type: Personal, Business, and Unknown. However, your server didn't appreciate Unknown which is why we are using Personal.

 

Another little note is that the sample program as written will no longer work because it hard codes a list id of 1 when adding a new contact which I'm sure was the id assigned to the first list that was created in a bew account before you made your change to 10-character ids. I was able to easily figure this out but somebody who is newly trying to understand how to use your api's might find it a little tough knowing what to do to fix the sample program.

Honored Contributor

Re: Can't Do AddContact

Thanks for the info about the address type and the list ID. The Address type UNKNOWN was previously supported under an older contact management system, but is no longer valid and needs to be removed from the SDK. As for the list ID, it looks like the example code should probably include a method to select lists as a way to resolve that.

 

I should be able to have an update on github for the address types pretty quickly, the update to the sample code to provide better list management may be a bit longer.

 

If you see anything else or have any other questions, please let me know!

 

Sincerely,

Elijah G.
API Support Engineer
Moderator

Re: Can't Do AddContact

Wanted to update this thread to report that we have fixed the error message to be more helpful.  In this scenario, you will now get a unique error_code that says that it was an invalid address type and a useful English error message explaining the same.  Thanks for reporting this!

Dave Berard
Senior Product Manager, Constant Contact