help us with create campaign error: 400

Participant

help us with create campaign error: 400

Hi There,
I have been trying to create a campaign using an xml as the following example but I got error 400. Could someone help me to go over it? How should I do it? If there is something wrong in the way I am doing it, please let me know.

 

<?xml version="1.0" encoding="UTF-8"?><entry xmlns="http://www.w3.org/2005/Atom">      <link href="/ws/customers/username/campaigns" rel="edit"/>      <id>http://api.constantcontact.com/ws/customers/username/campaigns</id>      <title type="text">test2</title>      <updated>2011-06-06T12:10:12+01:00</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/username/campaigns/1104270829168">                  <Name>test2</Name>                  <Status>draft</Status>                  <Date>2011-06-07T12:10:12+01:00</Date>                  <Subject>Test Email</Subject>                  <FromName>Company, LLC</FromName>                  <ViewAsWebpage>YES</ViewAsWebpage>                  <ViewAsWebpageLinkText></ViewAsWebpageLinkText>                  <ViewAsWebpageText></ViewAsWebpageText>                  <PermissionReminder>NO</PermissionReminder>                  <PermissionReminderText></PermissionReminderText>                  <GreetingSalutation>Dear</GreetingSalutation>                  <GreetingName>FirstName</GreetingName>                  <GreetingString>Greetings!</GreetingString>                  <OrganizationName>Company Name</OrganizationName>                  <OrganizationAddress1>Company Address</OrganizationAddress1>                  <OrganizationAddress2></OrganizationAddress2>                  <OrganizationAddress3></OrganizationAddress3>                  <OrganizationCity>Company City</OrganizationCity>                  <OrganizationState>Company State</OrganizationState>                  <OrganizationInternationalState></OrganizationInternationalState>                  <OrganizationCountry>us</OrganizationCountry>                  <OrganizationPostalCode>Company Zip</OrganizationPostalCode>                  <IncludeForwardEmail>NO</IncludeForwardEmail>                  <ForwardEmailLinkText>Forward email</ForwardEmailLinkText>                  <IncludeSubscribeLink>NO</IncludeSubscribeLink>                  <SubscribeLinkText>Subscribe me!</SubscribeLinkText>                  <EmailContentFormat>HTML</EmailContentFormat>                  <EmailContent>                        <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:cctd="http://www.constantcontact.com/cctd">                              <body>                                    <CopyRight>Copyright (c) 1996-2011 Constant Contact. All rights reserved. Except as permitted under a separatewritten agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on any Constant Contact site,including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, or distributed without theprior written permission of Constant Contact. For inquiries regarding reproduction or distribution of any Constant Contact material, pleasecontact legal@constantcontact.com.</CopyRight>                                    <OpenTracking/>                                    <!-- Do NOT delete previous line if you want to get statistics on the number of opened emails -->                                    <CustomBlock name="letter.intro" title="Personalization">                                          <Greeting/>                                    </CustomBlock>                              Hi there!</body>                        </html>                  </EmailContent>                  <EmailTextContent>                        <Text>                              <Greeting/>                        Hi there!</Text>                  </EmailTextContent>                  <StyleSheet></StyleSheet>                  <ContactLists>                        <ContactList id="http://api.constantcontact.com/ws/customers/username/lists/2">                              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/lists/2" rel="self"/>                        </ContactList>                  </ContactLists>                  <FromEmail>                        <Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">                              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self"/>                        </Email>                        <EmailAddress>me@me.com</EmailAddress>                  </FromEmail>                  <ReplyToEmail>                        <Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">                              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self"/>                        </Email>                        <EmailAddress>me@me.com</EmailAddress>                  </ReplyToEmail>            </Campaign>      </content>      <source>            <id>http://api.constantcontact.com/ws/customers/username/campaigns</id>            <title type="text">Campaigns for customer: UserName</title>            <link href="campaigns"/>            <link href="campaigns" rel="self"/>            <author>                  <name>username</name>            </author>            <updated>2011-06-06T12:10:12</updated>      </source></entry>

 

Thanks in advance...

1 REPLY 1
Moderator

Problem with the XML is that your EmailContent and EmailTextContent nodes are not XML encoded.  You were also missing a value for the ViewAsWebpageText and ViewAsWebpageLinkText with your ViewAsWebpage value set to YES (this makes these fields mandatory).  Making these fixes allowed me to create a Campaign in my account with your XML.  Here is the corrected XML:

 

 <?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/username/campaigns" rel="edit"/>
  <id>http://api.constantcontact.com/ws/customers/username/campaigns</id>
  <title type="text">test2</title>
  <updated>2011-06-06T12:10:12+01:00</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/username/campaigns/1104270829168">
      <Name>test2</Name>
      <Status>draft</Status>
      <Date>2011-06-07T12:10:12+01:00</Date>
      <Subject>Test Email</Subject>
      <FromName>Company, LLC</FromName>
      <ViewAsWebpage>YES</ViewAsWebpage>
      <ViewAsWebpageLinkText>Click Here</ViewAsWebpageLinkText>
      <ViewAsWebpageText>Having trouble viewing this email?</ViewAsWebpageText>
      <PermissionReminder>NO</PermissionReminder>
      <PermissionReminderText></PermissionReminderText>
      <GreetingSalutation>Dear</GreetingSalutation>
      <GreetingName>FirstName</GreetingName>
      <GreetingString>Greetings!</GreetingString>
      <OrganizationName>Company Name</OrganizationName>
      <OrganizationAddress1>Company Address</OrganizationAddress1>
      <OrganizationAddress2></OrganizationAddress2>
      <OrganizationAddress3></OrganizationAddress3>
      <OrganizationCity>Company City</OrganizationCity>
      <OrganizationState>Company State</OrganizationState>
      <OrganizationInternationalState></OrganizationInternationalState>
      <OrganizationCountry>us</OrganizationCountry>
      <OrganizationPostalCode>Company Zip</OrganizationPostalCode>
      <IncludeForwardEmail>NO</IncludeForwardEmail>
      <ForwardEmailLinkText>Forward email</ForwardEmailLinkText>
      <IncludeSubscribeLink>NO</IncludeSubscribeLink>
      <SubscribeLinkText>Subscribe me!</SubscribeLinkText>
      <EmailContentFormat>HTML</EmailContentFormat>
      <EmailContent>
&lt;html lang=&quot;en&quot; xml:lang=&quot;en&quot; xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:cctd=&quot;http://www.constantcontact.com/cctd&quot;&gt;
          &lt;body&gt;
            &lt;CopyRight&gt;Copyright (c) 1996-2011 Constant Contact. All rights reserved. Except as permitted under a separatewritten agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on any Constant Contact site,including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, or distributed without theprior written permission of Constant Contact. For inquiries regarding reproduction or distribution of any Constant Contact material, pleasecontact legal@constantcontact.com.&lt;/CopyRight&gt;
            &lt;OpenTracking/&gt;
            &lt;!-- Do NOT delete previous line if you want to get statistics on the number of opened emails --&gt;
            &lt;CustomBlock name=&quot;letter.intro&quot; title=&quot;Personalization&quot;&gt;
              &lt;Greeting/&gt;
            &lt;/CustomBlock&gt;                              Hi there!&lt;/body&gt;
          &lt;/html&gt;
        </EmailContent>
        <EmailTextContent>
Text&gt;
            &lt;Greeting/&gt;                        Hi there!&lt;/Text&gt;
          </EmailTextContent>
          <StyleSheet></StyleSheet>
          <ContactLists>
            <ContactList id="http://api.constantcontact.com/ws/customers/username/lists/2">
              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/lists/2" rel="self"/>
            </ContactList>
          </ContactLists>
          <FromEmail>
            <Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">
              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self"/>
            </Email>
            <EmailAddress>me@me.com</EmailAddress>
          </FromEmail>
          <ReplyToEmail>
            <Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">
              <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self"/>
            </Email>
            <EmailAddress>me@me.com</EmailAddress>
          </ReplyToEmail>
        </Campaign>
      </content>
      <source>
        <id>http://api.constantcontact.com/ws/customers/username/campaigns</id>
        <title type="text">Campaigns for customer: UserName</title>
        <link href="campaigns"/>
        <link href="campaigns" rel="self"/>
        <author>
          <name>username</name>
        </author>
        <updated>2011-06-06T12:10:12</updated>
      </source>
    </entry>
Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page