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 error when create a new contact

Highlighted
Frequent Visitor

400 error when create a new contact

I'm not able to figure out what I'm doing wrong.  I'm getting a 400 error when posting to:

 

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

 

Here is my xml:

 

<entry xmlns="http://www.w3.org/2005/Atom">  <title type="text"></title>  <updated>2011-08-25T01: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>bobp@vinomis.com</EmailAddress>      <OptInSource>ACTION_BY_CUSTOMER</OptInSource>      <ContactLists>        <ContactList id="http://api.constantcontact.com/ws/customers/***/lists/1" />      </ContactLists>    </Contact>  </content></entry>

 

List 1 is a valid list.  I get a 400 error back from the server.  Is there a way to get more information on what is causing the error?

 

 

1 REPLY 1
Highlighted
Employee

Re: 400 error when create a new contact

Hi,

It looks like the problem is with how your XML is formatted.  When I changed the spacing so that each node is on a separate line, it worked for me.  I have included an example below:

<entry xmlns="http://www.w3.org/2005/Atom"> 
<title type="text"></title>
<updated>2011-08-25T01: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>bobp@vinomis.com</EmailAddress>
<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/***/lists/1"/>     
</ContactLists>   
</Contact> 
</content>
</entry>

 

I hope this helps.  Please let me know if I can be of further assistance.

Matt R.
Support Engineer, Constant Contact
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