Reply
Occasional Participant
InfoSource
Posts: 3
Registered: ‎12-22-2010

400 Bad request

Hey,

 

We got our API keys and downloaded your test samples using C# (.Net_Campaign_examples) and tested to use them by replacing credentials however we are not able to create a new campaign and everytime we try we get Error 400 Bad Request. Any idea why we are getting the 400 error ??

 

Please have some guide us through this steps so we can create campaigns since this step is required for us to proto type this for our client to demostrate the integration btwn cosntant contact and our ERP system.

 

Regards

 

Occasional Participant
InfoSource
Posts: 3
Registered: ‎12-22-2010

Re: 400 Bad request while testing .Net C# example

Hey Guys,

 

We haven't heard back from anybody on this issue? So we did bit more testing and attached below is the XML ouput its trying to submit and maybe this will help you to resolve the issue.

 

I have changed the Account id as 2010 & the email id, other than that everything else is the sample data in the XML below and it throws an error of 404 bad request.

 

 <?xml version="1.0" encoding="UTF-8" ?>
- <entry xmlns="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/2010/campaigns" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/2010/campaigns</id>
  <title type="text">Aug 08 2011</title>
  <updated>2011-08-08T00:43:31.5710040-04: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/2010/campaigns/0000000000000">
  <Name>Aug 08 2011</Name>
  <Status>Draft</Status>
  <Date>2011-08-08T00:43:31.5710040-04:00</Date>
  <Subject>News from Info</Subject>
  <FromName>Info</FromName>
  <ViewAsWebpage>YES</ViewAsWebpage>
  <ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText>
  <ViewAsWebpageText>Having trouble viewing this email?</ViewAsWebpageText>
  <PermissionReminder>YES</PermissionReminder>
  <PermissionReminderText>You're receiving this email because of your relationship with 2010. Please confirm your continued interest in receiving email from us.</PermissionReminderText>
  <GreetingSalutation />
  <GreetingName>FirstName</GreetingName>
  <GreetingString />
  <OrganizationName>test</OrganizationName>
  <OrganizationAddress1>test</OrganizationAddress1>
  <OrganizationAddress2>test</OrganizationAddress2>
  <OrganizationAddress3>test</OrganizationAddress3>
  <OrganizationCity>fairfax</OrganizationCity>
  <OrganizationState>VA</OrganizationState>
  <OrganizationInternationalState />
  <OrganizationCountry>us</OrganizationCountry>
  <OrganizationPostalCode>22030</OrganizationPostalCode>
  <IncludeForwardEmail>YES</IncludeForwardEmail>
  <ForwardEmailLinkText />
  <IncludeSubscribeLink>YES</IncludeSubscribeLink>
  <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-2009 Constant Contact. All rights reserved. Except as permitted under a separate written 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 the prior written permission of Constant Contact. For inquiries regarding reproduction or distribution of any Constant Contact material, please contact 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></body></html></EmailContent>
  <EmailTextContent><Text>Copyright (c) 1996-2009 Constant Contact. All rights reserved. Except as permitted under a separate written 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 the prior written permission of Constant Contact. For inquiries regarding reproduction or distribution of any Constant Contact material, please contact legal@constantcontact.com.</Text></EmailTextContent>
  <StyleSheet />
- <ContactLists>
- <ContactList id="http://api.constantcontact.com/ws/customers/2010/lists/1">
  <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/2010/lists/1" rel="self" />
  </ContactList>
  </ContactLists>
- <FromEmail>
- <Email id="http://api.constantcontact.com/ws/customers/2010/settings/emailaddresses/1">
  <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/2010/settings/emailaddresses/1" rel="self" />
  </Email>
  <EmailAddress>info@info.com</EmailAddress>
  </FromEmail>
- <ReplyToEmail>
- <Email id="http://api.constantcontact.com/ws/customers/2010/settings/emailaddresses/1">
  <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/2010/settings/emailaddresses/1" rel="self" />
  </Email>
  <EmailAddress>info@info.com</EmailAddress>
  </ReplyToEmail>
  </Campaign>
  </content>
- <source>
  <id>http://api.constantcontact.com/ws/customers/2010/campaigns</id>
  <title type="text">Campaigns for customer: 2010</title>
  <link href="campaigns" />
  <link href="campaigns" rel="self" />
- <author>
  <name>2010</name>
  </author>
  <updated>2011-08-08T00:44:46.3132790-04:00</updated>
  </source>
  </entry>


CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

Re: 400 Bad request while testing .Net C# example

Hello,

 

I took a look at your XML and I believe the problem you are having is in three areas.  The first issue that would cause a 400 error is that it does not appear that your EmailContent or TextContent HTML tags are HTML encoded.  In order to post HTML in the XML, they must be encoded.

 

The second and third issues that would cause a 400 error is that the ForwardEmailLinkText and the SubscribeLinkText must both have content, if the IncludeSubscribeLink and IncludeForwardLink nodes are YES.

 

Once I did these changes I was able to post the email without a problem.

 

If you have any questions please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Occasional Participant
InfoSource
Posts: 3
Registered: ‎12-22-2010

Re: 400 Bad request while testing .Net C# example

Thanks that helped to submit the data and create new campaigns. I appreciate your help.