Reply
Advisor
ShawnM641
Posts: 22
Registered: ‎12-01-2011
Accepted Solution

The ever popular Error 400: The request contains...

I've stripped out everything I thought might be contributing to the problem and still can't get it to post. I am trying to create a campaign for a managed partner.
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
		  <link href="https://api.constantcontact.com/ws/customers/smckeefair/campaigns" rel="edit"/>
		  <id/>
		  <title type="text"/>
		  <updated>2011-12-19T11:56:10:282Z</updated>
		  <author>
		    <name/>
		  </author>
		  <content type="application/vnd.ctct+xml">
		    <Campaign id="" xmlns="http://ws.constantcontact.com/ns/1.0/">
		      <Name>Spring Newsletter</Name>
		      <Status>Draft</Status>
		      <Date>2011-12-19T11:56:10:282Z</Date>
		      <Subject>Spring Newsletter email</Subject>
		      <FromName/>
		      <ViewAsWebpage>NO</ViewAsWebpage>
		      <ViewAsWebpageLinkText/>
		      <ViewAsWebpageText/>
		      <PermissionReminder>NO</PermissionReminder>
		      <PermissionReminderText>Permission Reminder</PermissionReminderText>
		      <GreetingSalutation>Dear</GreetingSalutation>
		      <GreetingName>FirstName</GreetingName>
		      <GreetingString/>
		      <OrganizationName/>
		      <OrganizationAddress1/>
		      <OrganizationAddress2/>
		      <OrganizationAddress3/>
		      <OrganizationCity/>
		      <OrganizationState/>
		      <OrganizationInternationalState/>
		      <OrganizationCountry/>
		      <OrganizationPostalCode/>
		      <IncludeForwardEmail>NO</IncludeForwardEmail>
		      <ForwardEmailLinkText/>
		      <IncludeSubscribeLink>NO</IncludeSubscribeLink>
		      <SubscribeLinkText/>
		      <EmailContentFormat>HTML</EmailContentFormat>
		      <EmailContent/>
		      <EmailTextContent/>
		      <StyleSheet/>
		      <ContactLists/>
		      <FromEmail>
		        <Email id="">
		        </Email>
		        <EmailAddress>private@shawnmckee.net</EmailAddress>
		      </FromEmail>
		      <ReplyToEmail>
		        <Email id="">
		        </Email>
		        <EmailAddress>private@shawnmckee.net</EmailAddress>
		      </ReplyToEmail>
		    </Campaign>
		  </content>
		  <source>
		    <id>https://api.constantcontact.com/ws/customers/smckeefair/campaigns</id>
		    <title type="text">Campaigns for customer: smckeefair</title>
		    <link href="campaigns"/>
		    <link href="campaigns" rel="self"/>
		    <author>
		      <name>smckeefair</name>
		    </author>
		    <updated>2011-12-19T11:56:10:282Z</updated>
		  </source>
		</entry>
CTCT Employee
Andrew_W
Posts: 48
Registered: ‎04-12-2011

Re: The ever popular Error 400: The request contains...

Hi Shawn:

 

A properly formatted FromEmail and ReplyToEmail nodes include the ID and Links to those addresses.

 

<FromEmail>
        <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
          <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/settings/emailaddresses/1"
          rel="self" />
        </Email>
        <EmailAddress>joesflowers@example.com</EmailAddress>
      </FromEmail>

 

<FromEmail> and <ReplyToEmail> must be set with the account's confirmed email addresses and their values must be valid ID's from Account Settings and Email Address Resource.

 

Hope this helps, please let us know.

 

Thanks,

Andrew Weber
Associate Product Manager for EventSpot
Advisor
ShawnM641
Posts: 22
Registered: ‎12-01-2011

Re: The ever popular Error 400: The request contains...

I've been using the Coldfusion sample code and it didn't include the <link> elements when it built the XML. I've updated it to handle that. Still no joy. All the rest of the packet remains the same.

 

<FromEmail>
<Email id="http://api.constantcontact.com/ws/customers/smckeefair/contacts/1">
<link href="/ws/customers/smckeefair/contacts/1" rel="self" xmlns="http://www.w3.org/2005/Atom"/>
</Email>
<EmailAddress>private@shawnmckee.net</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email id="private@shawnmckee.net">
<link href="/ws/customers/smckeefair/contacts/1" rel="self" xmlns="http://www.w3.org/2005/Atom"/>
</Email>
<EmailAddress>http://api.constantcontact.com/ws/customers/smckeefair/contacts/1</EmailAddress>
</ReplyToEmail>

 

CTCT Employee
Andrew_W
Posts: 48
Registered: ‎04-12-2011

Re: The ever popular Error 400: The request contains...

Hey Shawn,

 

The link href is to a verified email address on the account.  The URI you should use is: 

/ws/customers/smckeefair/settings/emailaddresses/1
Andrew Weber
Associate Product Manager for EventSpot
Advisor
ShawnM641
Posts: 22
Registered: ‎12-01-2011

Re: The ever popular Error 400: The request contains...

[ Edited ]

Well I'm feeling fairly stupid for not noticing the rather major differences in those two but still no joy.

 

<FromEmail>
        <Email id="http://api.constantcontact.com/ws/customers/smckeefair/settings/emailaddresses/1">
       		<link href="/ws/customers/smckeefair/settings/emailaddresses/1" rel="self" xmlns="http://www.w3.org/2005/Atom"/>
        </Email>
        <EmailAddress>private@shawnmckee.net</EmailAddress>
</FromEmail>
<ReplyToEmail>
        <Email id="http://api.constantcontact.com/ws/customers/smckeefair/settings/emailaddresses/1">
       		<link href="/ws/customers/smckeefair/settings/emailaddresses/1" rel="self" xmlns="http://www.w3.org/2005/Atom"/>
        </Email>
        <EmailAddress>http://api.constantcontact.com/ws/customers/smckeefair/contacts/1</EmailAddress>
</ReplyToEmail>
CTCT Employee
Andrew_W
Posts: 48
Registered: ‎04-12-2011

Re: The ever popular Error 400: The request contains...

Hey Shawn,

 

I see a few more issues with the XML you provided.  A Campaign ID and FromName were missing and the Campaign link was incorrect.  You must have content in the email and text in the EmailTextContent; both need to be encoded.  Below is the correct XML you should have:

 

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
		  <link href="/ws/customers/smckeefair/campaigns" rel="edit"/>
		  <id>http://api.constantcontact.com/ws/customers/smckeefair/campaigns</id>
		  <title type="text"/>
		  <updated>2009-10-19T18:34:53.105Z</updated>
		  <author>
		    <name>my new test for today</name>
		  </author>
		  <content type="application/vnd.ctct+xml">
		    <Campaign id="http://api.constantcontact.com/ws/customers/smckeefair/campaigns/1100546096289" xmlns="http://ws.constantcontact.com/ns/1.0/">
		      <Name>Spring Newsletter randome number</Name>
		      <Status>Draft</Status>
		      <Date>2011-12-19T11:56:10:282Z</Date>
		      <Subject>Spring Newsletter email</Subject>
		      <FromName>My New Name</FromName>
		      <ViewAsWebpage>NO</ViewAsWebpage>
		      <ViewAsWebpageLinkText/>
		      <ViewAsWebpageText/>
		      <PermissionReminder>NO</PermissionReminder>
		      <PermissionReminderText>Permission Reminder</PermissionReminderText>
		      <GreetingSalutation>Dear</GreetingSalutation>
		      <GreetingName>FirstName</GreetingName>
		      <GreetingString/>
		      <OrganizationName/>
		      <OrganizationAddress1/>
		      <OrganizationAddress2/>
		      <OrganizationAddress3/>
		      <OrganizationCity/>
		      <OrganizationState/>
		      <OrganizationInternationalState/>
		      <OrganizationCountry/>
		      <OrganizationPostalCode/>
		      <IncludeForwardEmail>NO</IncludeForwardEmail>
		      <ForwardEmailLinkText/>
		      <IncludeSubscribeLink>NO</IncludeSubscribeLink>
		      <SubscribeLinkText/>
		      <EmailContentFormat>HTML</EmailContentFormat>
		      <EmailContent>&lt;html>&lt;body>test&lt;/body>&lt;/html></EmailContent>
		      <EmailTextContent>&lt;Text>Test&lt;/Text></EmailTextContent>
		      <StyleSheet/>
		      <ContactLists/>
		      <FromEmail>
        <Email id="http://api.constantcontact.com/ws/customers/smckeefair/settings/emailaddresses/1">
       		<link href="/ws/customers/smckeefair/settings/emailaddresses/1" rel="self" xmlns="http://www.w3.org/2005/Atom"/>
        </Email>
        <EmailAddress>private@shawnmckee.net</EmailAddress>
</FromEmail>
<ReplyToEmail>
        <Email id="http://api.constantcontact.com/ws/customers/smckeefair/settings/emailaddresses/1">
       		<link href="/ws/customers/smckeefair/settings/emailaddresses/1" rel="self" xmlns="http://www.w3.org/2005/Atom"/>
        </Email>
        <EmailAddress>http://api.constantcontact.com/ws/customers/smckeefair/contacts/1</EmailAddress>
</ReplyToEmail>
		    </Campaign>
		  </content>
		  <source>
		    <id>https://api.constantcontact.com/ws/customers/smckeefair/campaigns</id>
		    <title type="text">Campaigns for customer: smckeefair</title>
		    <link href="campaigns"/>
		    <link href="campaigns" rel="self"/>
		    <author>
		      <name>smckeefair</name>
		    </author>
		    <updated>2011-12-19T11:56:10:282Z</updated>
		  </source>
		</entry>

 

Hope this helps, let us know.

 

Thanks,

 

 

Andrew Weber
Associate Product Manager for EventSpot
Advisor
ShawnM641
Posts: 22
Registered: ‎12-01-2011

Re: The ever popular Error 400: The request contains...

Excellent, that fixed all of the vague error messages and I hit a few others that were fairly easy to figure out. I'd have to say the CF sample code is lacking.

CTCT Employee
Andrew_W
Posts: 48
Registered: ‎04-12-2011

Re: The ever popular Error 400: The request contains...

Thank you Shawn,

 

We are sorry for the inconvenience.  Sounds like it is time to revisit the code in the CF wrapper.

 

Thank you for the feedback,

Andrew Weber
Associate Product Manager for EventSpot
Occasional Participant
PaulT80
Posts: 4
Registered: ‎01-09-2012

Re: The ever popular Error 400: The request contains...

I am stuck when trying to create a campaign using the C# wrapper. I've attempted to compare the text outputted from the wrapper function to the sample provided in the documentation and while I see a few minor differences nothing seems to be jumping out at me as the error... Below is the data that is being submitted to the WebService. I tried to highlight the differences that I noticed including the date time field, the campaign ID and email IDs (all zeros?) and finally the lack of the closing tags for the elements that did not have data. I am sure this is something simple that I am missing but so far I've been able to do everything thing else but the campaign creation...

 

Any help you can offer would be greatly appreciated!!

 

Thanks!

 

Capture.JPG

Advisor
ShawnM641
Posts: 22
Registered: ‎12-01-2011

Re: The ever popular Error 400: The request contains...

I'm sure someone from CTCT will get to this soon but in the mean time I have one suggestion. I don't think 0 for the email address link is going to work. Needs to be number related to an actual address, probably 1 as that is the address of the CTCT account. Also don't follow it with a / just end with the number. The final email address tag also needs to be the full link not just the address.

 

As to the "missing" closing tag, the opening tag ending with a / closes it just like in XHTML.

 

Shawn