cancel
Showing results for 
Search instead for 
Did you mean: 
Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.

Error 415 using REST client and result of GET

Participant

Error 415 using REST client and result of GET

I keep getting error 415 Unsupported Media Type when doing a PUT to update a contact. It happened with the VBA code so I tried with the REST Client.  With the REST client, I did a GET (which worked fine), copied the results to the body for a PUT and did a PUT.  I still keep getting the 415 error.   Here is the XML I am using, note that   <content type="application/vnd.ctct+xml"> exactly matches the example given in the documentation for updating a contact.

 


<?xml version='1.0' encoding='UTF-8'?>

<entry xmlns="http://www.w3.org/2005/Atom">

  <link href="/ws/customers/jsteele%40health-mor.com/contacts/88" rel="edit" />

  <id>http://api.constantcontact.com/ws/customers/jsteele%40health-mor.com/contacts/88</id>

  <title type="text">Contact: user@address.com</title>

  <updated>2009-06-23T19:36:57.507Z</updated>

  <author>

    <name>Constant Contact</name>

  </author>

  <content type="application/vnd.ctct+xml">

    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/jsteele%40health-mor.com/contacts/88">

      <Status>Do Not Mail</Status>

      <EmailAddress>user@address.com</EmailAddress>

      <EmailType>HTML</EmailType>

      <Name>Donald Ayers</Name>

      <FirstName>Donald</FirstName>

      <MiddleName></MiddleName>

      <LastName>Ayers</LastName>

    </Contact>

  </content>

</entry>

8 REPLIES 8
Moderator

Hi Lee,   The most common

Hi Lee,


 


The most common reason for the situation you're describing is the content type field in the REST Client and VBA isn't being set correctly.  It should be set to "application/atom+xml" for the request content type.  This is no related to what the type attribue in the content node in the XML is, so this can sometimes be confusing.  This is the type of the content being sent in the request, which is Atom XML type.


 


 

Dave Berard
Senior Product Manager, Constant Contact
Participant

Now it says 403 Forbidden

Adding a header Content-Type of "application/atom+xml" changed the error message I am getting.  Of course the 403 Forbidden doesn't tell me much.  I am doing a PUT with the XML I received in response to a GET.

Moderator

403 Forbidden means that you

403 Forbidden means that you are trying to modify or create a resource which can't be modified or created (I.E. you are trying to update the contacts collection).  Here is an example of when this would happen:


 


You run a GET on the following URI: https://api.constantcontact.com/ws/customers/joesflowers/contacts


You than do a PUT (update) on the following URI: https://api.constantcontact.com/ws/customers/joesflowers/contacts


This will cause a 403 forbidden because you do not have rights to update that URI.


 


 


However, if you do a GET on this URI: https://api.constantcontact.com/ws/customers/joesflowers/contacts/1


And then do a PUT back to the same URI with the returned XML, it will work as you can update an idividual contact.


 


I see you provided the XML you're working with, what is the URI you are running the GET and PUT to?

Dave Berard
Senior Product Manager, Constant Contact
Participant

URI??

I am afraid I don't understand the question.  There is only one URI that I could have used to get the XML:


 


https://api.constantcontact.com/ws/customers/jsteele%40health-mor.com/contacts/88


 

Moderator

I'm sorry, I see the cause of

I'm sorry, I see the cause of the 403 in your XML Lee.  This is an error on what you're sending back in the PUT.  If you look at the status of this contact you'll see they are on the Do Not Mail list:


 


<Status>Do Not Mail</Status>


 


In order to move a contact from the DNM list to an active list, the action source must by ACTION_BY_CONTACT rather than ACTION_BY_CUSTOMER.  Adding this to your XML will fix the problem:


 


<OptInSource>ACTION_BY_CONTACT</OptInSource>


 


 


Please note, moving contacts off of the DNM list without a request from that contact is against Constant Contact's Terms & Condditions and can result in account termination.

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Participant

Not Changing the status of the contact

I am not trying to change the status of the contact.  I am only trying to udpate several of the fields.


 


The XML shows "<Status>Do Not Mail</Status>".  When I remove the "Status" tag, I still get the "403 Forbidden" response.   When I change the "<OptInSource>ACTION_BY_CUSTOMER</OptInSource>" to "<OptInSource>ACTION_BY_CONTACT</OptInSource>", I receive a response "204 No Content".


Maybe I am not allowed to update a contact in "Do Not Mail" status.  Using the REST client, for an ACTIVE contact, 10648, I tried doing a GET, pasting the response into the body and doing a PUT.  I receive the same "204 No Content" message.  Here is the XML for the ACTIVE client:


 


<?xml version='1.0' encoding='UTF-8'?>

<entry xmlns="http://www.w3.org/2005/Atom">

  <link href="/ws/customers/jsteele%40health-mor.com/contacts/10648" rel="edit" />

  <id>http://api.constantcontact.com/ws/customers/jsteele%40health-mor.com/contacts/10648</id>

  <title type="text">Contact: user@fmtc.com</title>

  <updated>2009-08-19T15:58:50.819Z</updated>

  <author>  </author>

  <content type="application/vnd.ctct+xml">

    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/jsteele%40health-mor.com/contacts/10648">

     <EmailAddress>user@fmtc.com</EmailAddress>

      <EmailType>HTML</EmailType>

      <CustomField1>277052</CustomField1>

     <OptInSource>ACTION_BY_CUSTOMER</OptInSource>

    </Contact>

  </content>

</entry>


It would help if you could send me some minimal XML that actually worked in the REST client to update a contact.


Lee Robinson

Moderator

Hi Lee,   204 No Content is a

Hi Lee,


 


204 No Content is a success message.  All messages returned in the 200-299 range are success messages in HTML.  400-499 are error messages due to content/request.  500-599 are Server failure messages.  


 


It looks like you're requests are going through correctly without any issues now.

Dave Berard
Senior Product Manager, Constant Contact
New Member

woops, i see

removed post