Reply
Occasional Contributor
ToddB12
Posts: 7
Registered: ‎12-14-2011
Accepted Solution

Code Samples: .NET (C#) Sample Forms Error 400: Bad Request

[ Edited ]

I do apologize as I know this has been asked before, however I am relatively new to the API and am not sure what may be wrong in my xml.

 

I downloaded the Sample Forms, and just tried simply adding a contact out of the box. I plugged in my API key and it retrieves my lists so I know it is connecting. However, when I click add, I get 'The remote server returned and error. (400) Bad Request.'

 

Here is my xml, pretty simple:

 

<entry xmlns=\"http://www.w3.org/2005/Atom\">
<title type=\"text\"></title>
<updated>2008-07-23T14:21:06.407Z</updated>
<author></author>
<id>data:,none</id>
<summary type=\"text\">Contact</summary>
<content type=\"application/vnd.ctct+xml\">
<Contact xmlns=\"http://ws.constantcontact.com/ns/1.0/\">
	<EmailAddress>john@doe.com</EmailAddress>
	<FirstName>John</FirstName>
	<MiddleName></MiddleName>
	<LastName>Doe</LastName>
	<HomePhone></HomePhone>
	<Addr1></Addr1>
	<Addr2></Addr2>
	<Addr3></Addr3>
	<City></City>
	<StateCode></StateCode>
	<StateName></StateName>
	<PostalCode></PostalCode>
	<SubPostalCode></SubPostalCode>
	<CountryCode></CountryCode>
	<CompanyName></CompanyName>
	<JobTitle></JobTitle>
	<WorkPhone></WorkPhone>
	<EmailType>HTML</EmailType>
	<Note></Note>
	<CustomField1></CustomField1>
	<CustomField2></CustomField2>
	<CustomField3></CustomField3>
	<CustomField4></CustomField4>
	<CustomField5></CustomField5>
	<CustomField6></CustomField6>
	<CustomField7></CustomField7>
	<CustomField8></CustomField8>
	<CustomField9></CustomField9>
	<CustomField10></CustomField10>
	<CustomField11></CustomField11>
	<CustomField12></CustomField12>
	<CustomField13></CustomField13>
	<CustomField14></CustomField14>
	<CustomField15></CustomField15>
	<ContactLists>
		<ContactList id=\"http://api.constantcontact.com/ws/customers/myaccountname/lists/1\"/>
		<ContactList id=\"http://api.constantcontact.com/ws/customers/myaccountname/lists/11\"/>
	</ContactLists>
</Contact>
</content>
</entry>"

 

What am I missing? Thanks!

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

Re: Code Samples: .NET (C#) Sample Forms Error 400: Bad Request

Hi Todd,

 

You are missing a node:

 

<OptInSource>ACTION_BY_CUSTOMER</OptInSource>

 

See this link for all required nodes.

Andrew Weber
Associate Product Manager for EventSpot
Occasional Contributor
ToddB12
Posts: 7
Registered: ‎12-14-2011

Re: Code Samples: .NET (C#) Sample Forms Error 400: Bad Request

That was it, thank you!