- Constant Contact Community
- :
- Developer Community
- :
- Developer Support – ask questions, find answers
- :
- 400 error while creating a campaign
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
400 error while creating a campaign
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-23-2012 09:07 AM
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/desig
<entry xmlns="http://www.w3.org/2005/Atom"><link href="/ws/customers/designhousedigital/campaigns" rel="edit"/><id>http://api.constantcontact.com/ws/customers/design housedigital/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/design housedigital/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><html lang="en" xml:lang="en"><body><p style="margin: 0px 0px 10px 0px;">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.</p><p style="font-weight: bold">Tuesday $1 kits are on sale through THURSDAY!</body></html></EmailContent><EmailTextContent><Text></Text></EmailTextContent><StyleSheet></StyleSheet><ContactLists><ContactList id="http://api.constantcontact.com/ws/customers/design housedigital/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/design housedigital/settings/emailaddresses/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/designhousedigital/settings/emailadd resses/1" rel="self"/></Email><EmailAddress>digi@designhousedigital.com</EmailAddress></FromEmail><ReplyToEmail><Email id="http://api.constantcontact.com/ws/customers/design housedigital/settings/emailaddresses/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/designhousedigital/settings/emailadd resses/1" rel="self"/></Email><EmailAddress>digi@designhousedigital.com</EmailAddress></ReplyToEmail></Campaign></content><source><id>http://api.constantcontact.com/ws/customers/design housedigital/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>
Solved! Go to Solution.
Re: 400 error while creating a campaign
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-23-2012 01:57 PM
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,
Support Engineer
Re: 400 error while creating a campaign
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-24-2012 12:48 AM
Yes, it worked. My campaign was created successfully. Thanks!
Mary
Re: 400 error while creating a campaign
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-24-2012 04:43 PM
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.
Support Engineer


