Reply
Occasional Participant
marybeshaw
Posts: 3
Registered: ‎10-25-2010
Accepted Solution

400 error while creating a campaign

Hi! I have been trying to write a  script to create an email campaign, and have run into some problems.  I get an HTTP 400 error.

 

I am using the php cc_class.php obtained from your web site.  I have been able to list contact lists, check to see if a contact exists, add contacts, and update contacts, so my authentication is set up correctly.  I am using the funciton createCampaignXML to generate the XML to send to the API.

 

I have validated the XML on w3schools, and no errors have been found.  I have also compared it against the sample campaign included with your API documentation and noticed nothing out of the ordinary. 

 

Is there a tool on your web site I can use to get more detailed information on what I can do to fix the error?

 

call path: https://api.constantcontact.com/ws/customers/designhousedigital/campaigns

 

<entry xmlns="http://www.w3.org/2005/Atom"><link href="/ws/customers/designhousedigital/campaigns" rel="edit"/><id>http://api.constantcontact.com/ws/customers/designhousedigital/campaigns</id><title type="text">testing</title><updated>2012-04-23T06:53:59+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/designhousedigital/campaigns/1100546096289"><Name>testing</Name><Status>Draft</Status><Date>2012-04-23T06:53:59 01:00</Date><Subject>testing</Subject><FromName>digi@designhousedigital.com</FromName><ViewAsWebpage>NO</ViewAsWebpage><ViewAsWebpageLinkText>YES</ViewAsWebpageLinkText><ViewAsWebpageText>YES</ViewAsWebpageText><PermissionReminder>NO</PermissionReminder><PermissionReminderText></PermissionReminderText><GreetingSalutation></GreetingSalutation><GreetingName></GreetingName><GreetingString></GreetingString><OrganizationName>Design House Digital</OrganizationName><OrganizationAddress1>4525 Haven Ln</OrganizationAddress1><OrganizationAddress2></OrganizationAddress2><OrganizationAddress3></OrganizationAddress3><OrganizationCity>Cedar Hills</OrganizationCity><OrganizationState>UT</OrganizationState><OrganizationInternationalState></OrganizationInternationalState><OrganizationCountry>us</OrganizationCountry><OrganizationPostalCode>84062</OrganizationPostalCode><IncludeForwardEmail>NO</IncludeForwardEmail><ForwardEmailLinkText>YES</ForwardEmailLinkText><IncludeSubscribeLink>YES</IncludeSubscribeLink><SubscribeLinkText></SubscribeLinkText><EmailContentFormat>HTML</EmailContentFormat><EmailContent>&lt;html lang="en" xml:lang="en"&gt;&lt;body&gt;&lt;p style="margin: 0px 0px 10px 0px;"&gt;Today we have 3 BRAND NEW digital kits on sale for just $1! After Thursday these kits will go back to regular price, so you have 3 days to pick up the 3 special-priced items. See our newest kits.&lt;/p&gt;&lt;p style="font-weight: bold"&gt;Tuesday $1 kits are on sale through THURSDAY!&lt;/body&gt;&lt;/html&gt;</EmailContent><EmailTextContent>&lt;Text&gt;&lt;/Text&gt;</EmailTextContent><StyleSheet></StyleSheet><ContactLists><ContactList id="http://api.constantcontact.com/ws/customers/designhousedigital/lists/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/designhousedigital/lists/1" rel="self"/></ContactList></ContactLists><FromEmail><Email id="http://api.constantcontact.com/ws/customers/designhousedigital/settings/emailaddresses/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/designhousedigital/settings/emailaddresses/1" rel="self"/></Email><EmailAddress>digi@designhousedigital.com</EmailAddress></FromEmail><ReplyToEmail><Email id="http://api.constantcontact.com/ws/customers/designhousedigital/settings/emailaddresses/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/designhousedigital/settings/emailaddresses/1" rel="self"/></Email><EmailAddress>digi@designhousedigital.com</EmailAddress></ReplyToEmail></Campaign></content><source><id>http://api.constantcontact.com/ws/customers/designhousedigital/campaigns</id><title type="text">Campaigns for customer: designhousedigital</title><link href="campaigns"/><link href="campaigns" rel="self"/><author><name>designhousedigital</name></author><updated>2012-04-23T06:53:59+01:00</updated></source></entry>
Mark-C
Posts: 181
Topics: 3
Kudos: 10
Solutions: 14
Registered: ‎07-23-2011

Re: 400 error while creating a campaign

Hello,

 

It looks like you're missing three things in what you've included here.  

 

1) You need to start with the xml declaration: <?xml version='1.0' encoding='UTF-8'?> at the top of your xml.

 

2) You need to include some content in the GreetingName element, (e.g., FirstName - or other field name), as that shouldn't be empty,

 

3) Since you have IncludeSubscribeLink element set to YES, you also need to include some content in the SubscribeLinkText element (e.g., Subscribe Me! ).

 

Fixing these things things resulted in a successful campaign creation in a test account for me, so I hope this is helpful.

 

Cheers,

Mark Coleman
Support Engineer
Occasional Participant
marybeshaw
Posts: 3
Registered: ‎10-25-2010

Re: 400 error while creating a campaign

Yes, it worked.  My campaign was created successfully.  Thanks!

 

Mary

Mark-C
Posts: 181
Topics: 3
Kudos: 10
Solutions: 14
Registered: ‎07-23-2011

Re: 400 error while creating a campaign

[ Edited ]

Hello Mary,

 

You're quite welcome, and I'm happy to hear that.  I used REST Client to troubleshoot your XML.  I highly recommend as a troubleshooting tool for REST API requests.  You can find information on setup and use at the link above.

Mark Coleman
Support Engineer