415 Unsupported Media Type

Participant

415 Unsupported Media Type

I am trying to update a users List Subscriptions from a form on our website..

 

I first do a Get to get the ContactID then do the PUT to this address and update Lists:

 

https://api.constantcontact.com/ws/customers/rplibrary/contacts/8365

 

Why would I be getting this error? Does my xml look ok?

 

I have tried both "ACTION_BY_CONTACT" and "ACTION_BY_CUSTOMER"

 

 

<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text" />
<updated>6/13/2012</updated>
<author>
<name>Constant Contact</name>
</author>
<id>http://api.constantcontact.com/ws/customers/rplibrary/contacts/8365</id>
<summary type="text">Contact</summary>
<content type="application/vnd.ctct+xml">
<Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/rplibrary/contacts/8365">
<EmailAddress>ctomlinson@nadicreative.com</EmailAddress>
<Name>Chuck Tomlinson</Name>
<FirstName>Chuck</FirstName>
<MiddleName></MiddleName>
<LastName>Tomlinson</LastName>
<OptInSource>ACTION_BY_CONTACT</OptInSource>
<HomePhone />
<Addr1 />
<Addr2 />
<Addr3 />
<City />
<StateCode />
<StateName />
<CountryCode />
<CountryName />
<PostalCode />
<SubPostalCode />
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/rplibrary/lists/6" />
<ContactList id="http://api.constantcontact.com/ws/customers/rplibrary/lists/10" />
</ContactLists>
</Contact>
</content>
</entry>

 

 

2 REPLIES 2
Participant

 

Sorry.. I found my own solution to the issue.. It was the Content-type not being set correctly..

 

I'm using ASP and I was checking for a POST and not a PUT to include the Content-type

 

I HAD:

 

If strMethod = "POST" Then
     objWinHttp.setRequestHeader "Content-type", "application/atom+xml"
End If

 

 

Changed TO:

 

If strMethod = "POST" OR strMethod = "PUT" Then
     objWinHttp.setRequestHeader "Content-type", "application/atom+xml"
End If

Ah, you beat me to the punch. Your XML seemed to be right, but I recreated the issue in RESTClient by submitted the request without the Content-type set in the request header.  I was just about to suggest you verify that this header was corrected set. Since you've already discovered that, however.  Let us know if you have any other questions.

 

Cheers,

Mark Coleman
Support Engineer
Developer Portal

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

Visit Page