Reply
Regular Visitor
StephenJ85
Posts: 2
Registered: ‎03-09-2012
Accepted Solution

Adding New Contact Record: 400 Error

[ Edited ]

Hello! I'm a developer trying to build a simple add contact script in .NET. (I'm talking about a brand-new contact here, not about adding an existing contact to a contact list.)  I'm authenticating fine using basic HTTPS, but I'm getting a 400 error every time I try to send new contact XML. According to the documentation, that means my XML is probably ill-formed, but I built my code based on the sample ASP.NET signup form project on SourceForge (http://sourceforge.net/projects/ctctnetcontact/).  Can someone please take a look and tell me what I'm missing?

 

<entry xmlns="http://www.w3.org/2005/Atom">
	<title type="text"></title>
	<updated>2012-03-19T11:08:23</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>email@domain.com</EmailAddress>
			<FirstName>Bobby</FirstName>
			<MiddleName></MiddleName>
			<LastName>Tester</LastName>
			<HomePhone></HomePhone>
			<Addr1></Addr1>
			<Addr2></Addr2>
			<Addr3></Addr3>
			<City></City>
			<StateCode>WV</StateCode>
			<statename>West Virginia</statename>
			<postalcode></postalcode>
			<subpostalcode></subpostalcode>
			<countrycode></countrycode>
			<companyname></companyname>
			<jobtitle></jobtitle>
			<workphone></workphone>
			<EmailType>HTML</EmailType>
			<optinsource>ACTION_BY_CUSTOMER</optinsource>
			<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/ADSNTLmktg/lists/4" />
			</ContactLists>
		</Contact>
	</content>
</entry>

 

Richard_M
Posts: 30
Topics: 0
Kudos: 1
Solutions: 3
Registered: ‎02-15-2011

Re: Adding New Contact Record: 400 Error

[ Edited ]

Hi Stephen,

 

I notice in your XML that many of the tags are all lower-case. However, XML is case sensitive. So, for example, you have <optinsource>, but the correct casing is <OptInSource>. Our XML elements are camel cased.

 

Regards,

Richard Maxwell
Support Engineer, Constant Contact
Regular Visitor
StephenJ85
Posts: 2
Registered: ‎03-09-2012

Re: Adding New Contact Record: 400 Error

Thank you sincerely!  I'm not sure how some of the tags got that way, since I literally copy-pasted right out of the sample project.  But sure enough, the sample project had good capitalization and my code did not.  (I think maybe it was because, to start with, I commented out those particular lines of code... maybe Visual Studio did something crazy, or else I accidently hit some other shortcut while those lines were highlighted).

 

In any case, I fixed the capitalization and now I'm set.  Thanks for your help!