Error 400: The request contains errors in the common Atom sections

Occasional Participant

Error 400: The request contains errors in the common Atom sections

I am getting this error from your API...

 

Error 400: The request contains errors in the common Atom sections, which lie outside or , such as , ,or .

 

I have tried using a variety of XML data structures as outlined in forums on on this site but still cannot get it to work correctly.

 

Here's the XML I currently sending...

<entry>
<link href="/ws/customers/{username}/contacts/794" rel="edit">
<id>http://api.constantcontact.com/ws/customers/{username}/contacts/794</id>
<title
type="text">Contact: test@test.com</title>
<updated>2012-11-25T03:43:58.301Z</updated>
<author>
<name>Constant Contact</name>
</author>
<content type="application/vnd.ctct+xml">
<contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/{username}/contacts/794">
<status>Active</status>
<emailaddress>test@test.com</emailaddress>
<emailtype>HTML</emailtype>
<name></name>
<optintime>2012-10-25T22:35:18.308Z</optintime>
<optinsource>ACTION_BY_CUSTOMER</optinsource>
</contact>
</content>
</entry>

4 REPLIES 4
Highlighted
Moderator

Re: Error 400: The request contains errors in the common Atom sections

Hi Molly,

 

What action are you trying to complete with this XML? Are you attempting to create a new contact or update an existing one?

 

Thanks,

Nick Galbraith
Support Engineer
Highlighted
Occasional Participant

Re: Error 400: The request contains errors in the common Atom sections

Hi.  My name is actually Shane.  I am logging in on behalf of my client as their developer.

 

I am just trying to add a new contact.

 

Thank you

 

Shane Larson

Highlighted
Moderator

Re: Error 400: The request contains errors in the common Atom sections

Hi Shane,

 

There are a few formatting problems with the XML that will cause it to give a 400. When creating a contact, you don't need to pass an ID, as the system will create one for you. You also need to specify at least one list to add the contact to. Here is a snippet of XML that should work for you.

 

<entry xmlns="http://www.w3.org/2005/Atom">
  <title type="text">entry</title>
  <updated>2008-07-23T14: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>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/{username}/lists/1" />
      </ContactLists>
    </Contact>
  </content>
</entry>

 

Nick Galbraith
Support Engineer
Highlighted
Occasional Participant

Re: Error 400: The request contains errors in the common Atom sections

That was a part of my issue.  And I needed to change my OptInSource to ACTION_BY_CUSTOMER.

 

thanks for the help

Developer Portal

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