The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

400 Bad Request

Highlighted
Occasional Participant

400 Bad Request

I can't seem to pass a new customer successfully.  I'm getting a 400 error when I attempt to post the following xml.  I took the "basic" example and added a few extra fields from the documentation.  Does the error mean the xml is malformed or that a field has an error?


 


<?xml version="1.0" encoding="UTF-8"?>


<entry xmlns="http://www.w3.org/2005/Atom">


<title type="text"> </title>


<updated>2010-06-22T14:21:06.407Z</updated>


<author></author>


<id>data:,none</id>


<summary type="text">Contact</summary>


<content type="application/vnd.ctct+xml">


<Contact xmlns="http://ws.constantcontact.com/ns/1.0/">


<EmailAddress>test@test.com</EmailAddress>


<OptInSource>ACTION_BY_CONTACT</OptInSource>


<FirstName>Test</FirstName>


<LastName>Mctest</LastName>


<Addr1>123 address</Addr1>


<City>city</City>


<StateCode>FL</StateCode>


<CountryCode>US</CountryCode>


<PostalCode>12345</PostalCode>


<ContactLists>


<ContactList id="http://api.constantcontact.com/ws/customers/braindongle/lists/active" />


</ContactLists>


</Contact>


</content>


</entry>


 

5 REPLIES 5
Highlighted
Employee

Re: 400 Bad Request

I was able to get your XML to successfully create a contact in my account by changing:


<ContactList id="http://api.constantcontact.com/ws/customers/braindongle/lists/active" />


 


To an actual list id, such  as:


 


<ContactList id="http://api.constantcontact.com/ws/customers/braindongle/lists/1" />


 


You can obtain all of your list id's by performing an http get on the url format https://api.constantcontact.com/ws/customers/{user-name}/lists. You can find more information on this under Getting a Listing of Contact Lists


 


If you are still running into issues with your XML after making your modification, please let us know and we will be happy to look into it. Thank You.

David J

Highlighted
Occasional Participant

I can't seem to get it do

I can't seem to get it do anything other than 400.  If I remove the auth headers I start getting 401's like you would expect, but no matter what else I pass I get 400 back.


This was my original try:


 


<?xml version="1.0" encoding="UTF-8"?>


<entry xmlns="http://www.w3.org/2005/Atom">


<title type="text"> </title>


<updated>2010-06-22T14:21:06.407Z</updated>


<author></author>


<id>data:,none</id>


<summary type="text">Contact</summary>


<content type="application/vnd.ctct+xml">


<Contact xmlns="http://ws.constantcontact.com/ns/1.0/">


<EmailAddress>test@test.com</EmailAddress>


<OptInSource>ACTION_BY_CONTACT</OptInSource>


<FirstName>Test</FirstName>


<LastName>Mctest</LastName>


<Addr1>123 address</Addr1>


<City>city</City>


<StateCode>FL</StateCode>


<CountryCode>US</CountryCode>


<PostalCode>12345</PostalCode>


<ContactLists>


<ContactList id="http://api.constantcontact.com/ws/customers/braindongle/lists/1" />


</ContactLists>


</Contact>


</content>


</entry>


 

 

Highlighted
Employee

Re: I can't seem to get it do

I took the XML that you just posted and used it to successfully create a contact in my account without any modifications using the REST Client, which a very helpful tool for testing XML outside of your application. It sounds like the XML may be getting modified before being sent to Constant Contact, as the XML you posted here is correct.


If you could please reply to this post with your code, or send it to our webservices support team and we would be happy to take a look at it and see if we can provide some more detailed feedback.

David J

Highlighted
Occasional Participant

 I'm using a regular POST

 I'm using a regular POST to


https://api.constantcontact.com/ws/customers/braindongle/contacts


the header has:



  • Authorization

  • Content-Type


anything obvious I'm missing?


 

Highlighted
Employee

Re: I'm using a regular POST

If you were having an error with you're content-type (which should be 'application/atom+xml', that would give you an error 415. If you were unauthorized you would receive an error 401. Without seeing the rest of your code it is hard for me to go into much further detail about where the problem could be.


I can however verify that the issue is not in the structure of your XML, as this successfully works for me. I would recommend taking a look at the REST Client as this is a great resource for testing your XML requests and retreiving detailed error messages. Again, if you would like to send everything you have over to our webservices support team I would be happy to take a look.

David J

Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured