Adding New Contact Record: 400 Error

SOLVED
Go to solution
StephenJ85
Occasional Participant

Adding New Contact Record: 400 Error

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>

 

1 ACCEPTED SOLUTION
Richard_M
Member

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

View solution in original post

2 REPLIES 2
Richard_M
Member

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

View solution in original post

StephenJ85
Occasional Participant

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!

Developer Portal

View API documentation, code samples, get your API key.

Visit Page