I am using Classic ASP and vbScript to access the Constant Contact API. I have used the samples in these forums to create a function to do the HTTP request.
It is working correctly for any of the GET functions (lists, members and member information)
However, when I try to do a post, it is not functioning correclty and I am getting error 400.
Here is the xml that I am sending to the HTTP request:
<title type="text"> </title> <updated>12/15/2010</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/"> <EmailType>HTML</EmailType> <EmailAddress>email@example.com</EmailAddress> <FirstName>Jane</FirstName> <LastName>Doe</LastName> <OptInSource>ACTION_BY_CONTACT</OptInSource> <ContactLists> <ContactList id="http://api.constantcontact.com/ws/customers/BeckerHolding/lists/1" /> </ContactLists> </Contact> </content> </entry>
What could be wrong?
I have been able to successfully create a contact in my account using the REST Client with the XML that you posted. The only reason I could see this throwing back a 400 error would be if you did not have a list with the Id of "
http://api.constantcontact.com/ws/customers/BeckerHolding/lists/1" in your account. Provided that list exists, the issue must be something related to the request itself.
Would you be able to post the code you are using to create a contact and I would be happy to take a closer look?
I just realized what the issue was....
In my function to make the call, I add "application/atom+xml" to the header if the method is "POST"
However, I was passing in "Post" and it didn't had the appropriate header information. Now that I make sure the method is in Upper case, the header is correct and I was able to add the user.
Thanks for your time and help.