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.

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

Highlighted
Participant

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

 Hi I'm getting the Error 400: The request contains errors in the common Atom sections, which lie outside or , such as , , or  when i'm trying to create a new campaign,


 


here is my xml code



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


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


  <id>http://api.constantcontact.com/ws/customers/athleticquest/campaigns</id>


  <title type="text">API Test Email</title>


  <updated>#dateformat(now(), "yyyy-mm-dd")#T#TimeFormat(now(), "HH:mm:ss:l")#Z</updated>


  <author>


    <name>Constant Contact</name>


  </author>


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


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


      <Name>API Test Email</Name>


      <Status>Draft</Status>


      <Date>#dateformat(now(), "yyyy-mm-dd")#T#TimeFormat(now(), "HH:mm:ss:l")#Z</Date>


      <Subject>Enter email subject here</Subject>


      <FromName>AthleticQuest</FromName>


      <ViewAsWebpage>NO</ViewAsWebpage>


      <ViewAsWebpageLinkText></ViewAsWebpageLinkText>


      <ViewAsWebpageText></ViewAsWebpageText>


      <PermissionReminder>YES</PermissionReminder>


      <PermissionReminderText>You're receiving this email because of your relationship with ctct. 


Please &lt;ConfirmOptin>&lt;a>confirm&lt;/a>&lt;/ConfirmOptin> 


your continued interest in receiving email from us.</PermissionReminderText>


      <GreetingSalutation>Dear</GreetingSalutation>


      <GreetingName>FirstName</GreetingName>


      <GreetingString>Greetings!</GreetingString>


      <OrganizationName>AthleticQuest</OrganizationName>


      <OrganizationAddress1>123 wsw st</OrganizationAddress1>


      <OrganizationAddress2></OrganizationAddress2>


      <OrganizationAddress3></OrganizationAddress3>


      <OrganizationCity>Ashland</OrganizationCity>


      <OrganizationState>MA</OrganizationState>


      <OrganizationInternationalState></OrganizationInternationalState>


      <OrganizationCountry>US</OrganizationCountry>


      <OrganizationPostalCode>32423</OrganizationPostalCode>


      <IncludeForwardEmail>NO</IncludeForwardEmail>


      <ForwardEmailLinkText></ForwardEmailLinkText>


      <IncludeSubscribeLink>NO</IncludeSubscribeLink>


      <SubscribeLinkText></SubscribeLinkText>


      <EmailContentFormat>HTML</EmailContentFormat>


      <EmailContent>&lt;html>&lt;body>This is a test &lt;/body>&lt;/html></EmailContent>


      <TextContent>&lt;Text>This is the text version.&lt;/Text></TextContent>


      <ContactLists></ContactLists>


       <FromEmail>


       cphongsavath@athleticquest.net


      </FromEmail>


      <ReplyToEmail>


       cphongsavath@athleticquest.net


      </ReplyToEmail>


    </Campaign>


  </content>


  <source>


    <id>http://api.constantcontact.com/ws/customers/athleticquest/campaigns</id>


    <title type="text">Campaigns for customer: athleticquest</title>


    <link href="campaigns" />


    <link href="campaigns" rel="self" />


    <author>


      <name>athleticquest</name>


    </author>


    <updated>#dateformat(now(), "yyyy-mm-dd")#T#TimeFormat(now(), "HH:mm:ss:l")#Z</updated>


  </source>


</entry>


 


Chris



 

3 REPLIES 3
Highlighted
Occasional Advisor

Re: Error 400

Hello Chris,


After looking at your XML, I have noticed several elements that could be causing this issue:


 


-The updated nodes are currently filled with "#dateformat(now(), "yyyy-mm-dd")#T#TimeFormat(now(), "HH:mm:ss:l")#Z"


Because we use the Atom specification for XML, the updated fields are required even though they are not used by the server and are replaced upon a successful contact creation. Using any properly formatted timestamp such as 2009-10-19T19:36:12.622Z will work.


-The TextContent node should instead be EmailTextContent


-Your FromEmail, and ReplyToEmail must also contain an Email and Link child element


-Your ContactLists node must also contain a ContactList and Link child element.


 


Please use the following updated XML as a template for future email campaign creations:


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

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

  <link href="/ws/customers/athleticquest/campaigns" rel="edit" />

  <id>http://api.constantcontact.com/ws/customers/athleticquest/campaigns</id>

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

  <updated>2009-10-19T19:36:12.622Z</updated>

  <author>

    <name>Constant Contact</name>

  </author>

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

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

      <Name>API Test Email</Name>

      <Status>Draft</Status>

      <Date>2009-10-19T19:36:12.622Z</Date>

      <Subject>Enter email subject here</Subject>

      <FromName>AthleticQuest</FromName>

      <ViewAsWebpage>NO</ViewAsWebpage>

      <ViewAsWebpageLinkText></ViewAsWebpageLinkText>

      <ViewAsWebpageText></ViewAsWebpageText>

      <PermissionReminder>YES</PermissionReminder>

      <PermissionReminderText>You're receiving this email because of your relationship with ctct.

Please &lt;ConfirmOptin>&lt;a>confirm&lt;/a>&lt;/ConfirmOptin>

your continued interest in receiving email from us.</PermissionReminderText>

      <GreetingSalutation>Dear</GreetingSalutation>

      <GreetingName>FirstName</GreetingName>

      <GreetingString>Greetings!</GreetingString>

      <OrganizationName>AthleticQuest</OrganizationName>

      <OrganizationAddress1>123 wsw st</OrganizationAddress1>

      <OrganizationAddress2></OrganizationAddress2>

      <OrganizationAddress3></OrganizationAddress3>

      <OrganizationCity>Ashland</OrganizationCity>

      <OrganizationState>MA</OrganizationState>

      <OrganizationInternationalState></OrganizationInternationalState>

      <OrganizationCountry>US</OrganizationCountry>

      <OrganizationPostalCode>32423</OrganizationPostalCode>

      <IncludeForwardEmail>NO</IncludeForwardEmail>

      <ForwardEmailLinkText></ForwardEmailLinkText>

      <IncludeSubscribeLink>NO</IncludeSubscribeLink>

      <SubscribeLinkText></SubscribeLinkText>

      <EmailContentFormat>HTML</EmailContentFormat>

      <EmailContent>&lt;html>&lt;body>This is a test &lt;/body>&lt;/html></EmailContent>

      <EmailTextContent>&lt;Text>This is the text version.&lt;/Text></EmailTextContent>

      <StyleSheet></StyleSheet>

      <ContactLists>

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

          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/athleticquest/lists/1" rel="self" />

        </ContactList>

      </ContactLists>

      <FromEmail>

        <Email id="http://api.constantcontact.com/ws/customers/athleticquest/settings/emailaddresses/1">

          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/athleticquest/settings/emailaddresses/1"

          rel="self" />

        </Email>

        <EmailAddress>athleticquest@example.com</EmailAddress>

      </FromEmail>

      <ReplyToEmail>

        <Email id="http://api.constantcontact.com/ws/customers/athleticquest/settings/emailaddresses/1">

          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/athleticquest/settings/emailaddresses/1"

          rel="self" />

        </Email>

        <EmailAddress>athleticquest@example.com</EmailAddress>

      </ReplyToEmail>

    </Campaign>

  </content>

  <source>

    <id>http://api.constantcontact.com/ws/customers/athleticquest/campaigns</id>

    <title type="text">Campaigns for customer: athleticquest</title>

    <link href="campaigns" />

    <link href="campaigns" rel="self" />

    <author>

      <name>athleticquest</name>

    </author>

    <updated>2009-10-19T19:36:12.622Z</updated>

  </source>

</entry>


More information regarding the creation of an email campaign can be found at http://developer.constantcontact.com/doc/manageCampaigns#create_campaign

Andrew T

Support Engineer, Constant Contact

Highlighted
Senior Member

Re: Error 400

I'm getting error 400: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>.

 

Here is my code :

<?xml version='1.0' encoding='UTF-8' ?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <link href="/ws/customers/[Redacted]/campaigns" rel="edit" />
    <id>http://api.constantcontact.com/ws/customers/[Redacted]/campaigns</id>
    <title type="text">Newsletter 2013.08.12</title>
    <updated>2013-08-12T15:09:46.105Z</updated>
    <author>
    <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
    <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/[Redacted]/campaigns/0000000000000" >
    <Name>Newsletter 2013.08.12</Name>
    <Status>Draft</Status>
    <Date>2013-08-12T15:09:42.105Z</Date>
    <Subject>Nail Splash: Long-Wearing Polish Without The Harsh Removal Hassle? Oh Yeah, It's For Real</Subject>
    <FromName>Nail Splash</FromName>
    <ViewAsWebpage>NO</ViewAsWebpage>
    <ViewAsWebpageLinkText></ViewAsWebpageLinkText>
    <ViewAsWebpageText></ViewAsWebpageText>
    <PermissionReminder>NO</PermissionReminder>
    <PermissionReminderText></PermissionReminderText>
    <GreetingSalutation></GreetingSalutation>
    <GreetingName>None</GreetingName>
    <GreetingString></GreetingString>
    <OrganizationName>Nail Splash</OrganizationName>
    <OrganizationAddress1></OrganizationAddress1>
    <OrganizationAddress2></OrganizationAddress2>
    <OrganizationAddress3></OrganizationAddress3>
    <OrganizationCity></OrganizationCity>
    <OrganizationState>IL</OrganizationState>
    <OrganizationInternationalState></OrganizationInternationalState>
    <OrganizationCountry>US</OrganizationCountry>
    <OrganizationPostalCode></OrganizationPostalCode>
    <IncludeForwardEmail>NO</IncludeForwardEmail>
    <ForwardEmailLinkText></ForwardEmailLinkText>
    <IncludeSubscribeLink>NO</IncludeSubscribeLink>
    <SubscribeLinkText></SubscribeLinkText>
    <EmailContentFormat>HTML</EmailContentFormat>
    <EmailContent>
    <html>
        <head>
        </head>
        <body style='margin: 0;'>
        </body>
        </html>
    </EmailContent>
    <EmailTextContent>Nail Splash</EmailTextContent>
    <StyleSheet></StyleSheet>
    <Urls></Urls>
    <ContactLists>
    <ContactList id="http://api.constantcontact.com/ws/customers/[Redacted]/lists/37">
    <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/[Redacted]/lists/37" rel="self" />
    </ContactList>
    </ContactLists>
    <FromEmail>
    <Email id="http://api.constantcontact.com/ws/customers/[Redacted]/settings/emailaddresses/2">
    <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/[Redacted]/settings/emailaddresses/2" rel="self" />
    </Email>
    <EmailAddress>[Redacted]</EmailAddress>
    </FromEmail>
    <ReplyToEmail>
    <Email id="http://api.constantcontact.com/ws/customers/[Redacted]/settings/emailaddresses/2">
    <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/[Redacted]/settings/emailaddresses/2" rel="self" />
    </Email>
    <EmailAddress>[Redacted]</EmailAddress>
    </ReplyToEmail>
    </Campaign>
    </content>
    <source>
    <id>http://api.constantcontact.com/ws/customers/[Redacted]/campaigns</id>
    <title type="text">Campaigns for customer: [Redacted]</title>
    <link href="campaigns" />
    <link href="campaigns" rel="self" />
    <author>
    <name>[Redacted]</name>
    </author>
    <updated>2013-08-12T15:10:03.105Z</updated>
    </source>
</entry>

 

Highlighted
Honored Contributor

Re: Error 400

Hello,

 

I've looked over your XML and found that the only problem was that you did not encode the characters for your email content. In order to create campaigns, the content must be encoded so that it can be read as a simple string. Here's an example of the change.

 

Before:

        <html>
        <head>
        </head>
        <body style='margin: 0;'>
        </body>
        </html>

 

After:

        &lt;html&gt;
        &lt;head&gt;
        &lt;/head&gt;
        &lt;body style='margin: 0;'&gt;
        &lt;/body&gt;
        &lt;/html&gt;

 

If you're working in a PHP application, you can run your HTML content through the htmlspecialchars() function to automate this process. Let me know if you have any questions!

 

P.S. I have edited your post to remove some sensitive information that was inlcuded so that it does not end up in the wrong hands.

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
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