The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

415 Unsupported Media Type

Highlighted
Frequent Visitor

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
Highlighted
Frequent Visitor

Re: 415 Unsupported Media Type

 

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

Highlighted
Trusted Contributor

Re: 415 Unsupported Media Type

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

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured