Reply
Member
NickC63
Posts: 2
Registered: ‎08-16-2011
Accepted Solution

Error 415 when updating contact lists

I'm trying to update a contact and I believe I'm doing everything right.  However, I receive the following error:

 

Error 415: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>.

 

 

I'm trying to add the contact to another contact list and I'm using PUT with a modified version of the data I receive from a GET on that contact.  Here's the XML that I'm trying to PUT

 

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
	<link href="/ws/customers/TrellistNick/contacts/1" rel="edit"></link>
	<id>http://api.constantcontact.com/ws/customers/TrellistNick/contacts/1</id>
	<title type="text">Contact: ncohen@trellist.com</title>
	<updated>2011-08-18T21:00:53.503Z</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/TrellistNick/contacts/1">
			<Status>Active</Status>
			<EmailAddress>ncohen@trellist.com</EmailAddress>
			<EmailType>HTML</EmailType>
			<Name>Nick Cohen</Name>
			<FirstName>Nick</FirstName>
			<MiddleName></MiddleName>
			<LastName>Cohen</LastName>
			<JobTitle></JobTitle>
			<CompanyName></CompanyName>
			<HomePhone></HomePhone>
			<WorkPhone></WorkPhone>
			<Addr1></Addr1>
			<Addr2></Addr2>
			<Addr3></Addr3>
			<City></City>
			<StateCode></StateCode>
			<StateName></StateName>
			<CountryCode></CountryCode>
			<CountryName></CountryName>
			<PostalCode></PostalCode>
			<SubPostalCode></SubPostalCode>
			<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/TrellistNick/lists/1">
					<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/TrellistNick/lists/1" rel="self"></link>
					<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
					<OptInTime>2011-08-16T18:50:52.361Z</OptInTime>
				</ContactList>
				<ContactList id="http://api.constantcontact.com/ws/customers/TrellistNick/lists/3">
					<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/TrellistNick/lists/3" rel="self"></link>
					<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
					<OptInTime>2011-08-18T21:00:53.519Z</OptInTime>
				</ContactList>
				<ContactList id="http://api.constantcontact.com/ws/customers/TrellistNick/lists/2">
					<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/TrellistNick/lists/2" rel="self"></link>
					<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
					<OptInTime>2011-08-16T18:50:52.361Z</OptInTime>
				</ContactList>
			</ContactLists>
			<Confirmed>true</Confirmed>
			<InsertTime>2011-08-16T18:50:52.358Z</InsertTime>
			<LastUpdateTime>2011-08-18T21:00:53.503Z</LastUpdateTime>
		</Contact>
	</content>
	<source>
		<id>http://api.constantcontact.com/ws/customers/TrellistNick/contacts</id>
		<title type="text">Contacts for Customer: TrellistNick</title>
		<link href="contacts"></link>
		<link href="contacts" rel="self"></link>
		<author>
			<name>TrellistNick</name>
		</author>
		<updated>2011-08-22T18:30:28.797Z</updated>
	</source>
</entry>

 

All I've done to the information that I receive is add the third <ContactList></ContactList> membership.  Any help would be much appreciated. 

Ryan_D
Posts: 453
Topics: 0
Kudos: 20
Solutions: 21
Registered: ‎06-28-2011

Re: Error 415 when updating contact lists

Hi Nick,

 

It sounds like your headers may not be being set.  When you do a PUT to your Contact you need to specify that you are setting your Content-Type to application/atom+xml. 

 

Please let me know if this works for you.

Ryan Davis
Support Engineer, Constant Contact
Member
NickC63
Posts: 2
Registered: ‎08-16-2011

Re: Error 415 when updating contact lists

Thanks for the tip Ryan...that worked.  I re-used too much of my code from my GET function and forgot that the content-type header needed to be set for the PUT request. 

 

Thanks again,

-Nick

Occasional Contributor
BonnieS78
Posts: 3
Registered: ‎10-07-2012

Re: Error 415 when updating contact lists

[ Edited ]

Hi Ryan ,

 Me also got the same error like   "Error 415: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>."

 

 

 

 

my code is

 

 

entry
XmlText  
XmlAttributes struct
xmlns http://www.w3.org/2005/Atom
title
XmlText  
XmlAttributes struct
type text
updated
XmlText 2012-10-26T03:18:05:74Z
author
XmlText  
id
XmlText 1022
summary
XmlText Contact
XmlAttributes struct
type text
content
XmlText  
XmlAttributes struct
type application/Atom+xml
Contact
XmlText  
XmlAttributes struct
xmlns http://ws.constantcontact.com/ns/1.0/
EmailAddress
XmlText tnorthru@yahoo.com
EmailType
XmlText  
FirstName
XmlText  
MiddleName
XmlText  
LastName
XmlText  
JobTitle
XmlText  
CompanyName
XmlText  
WorkPhone
XmlText  
HomePhone
XmlText  
Addr1
XmlText  
Addr2
XmlText  
Addr3
XmlText  
City
XmlText  
StateCode
XmlText  
StateName
XmlText  
CountryCode
XmlText  
PostalCode
XmlText  
SubPostalCode
XmlText  
Note
XmlText  
CustomField1
XmlText  
CustomField2
XmlText  
CustomField3
XmlText  
CustomField4
XmlText  
CustomField5
XmlText  
CustomField6
XmlText  
CustomField7
XmlText  
CustomField8
XmlText  
CustomField9
XmlText  
CustomField10
XmlText  
CustomField11
XmlText  
CustomField12
XmlText  
CustomField13
XmlText  
CustomField14
XmlText  
CustomField15
XmlText  
Note
XmlText  
OptInSource
XmlText ACTION_BY_CUSTOMER
ContactLists
XmlText  
ContactList
XmlText  
XmlAttributes struct
id http://api.constantcontact.com/ws/customers/username/lists/20       

 

PLease let me know solution

thanks

Shannon_W
Posts: 707
Topics: 11
Kudos: 43
Solutions: 38
Registered: ‎10-24-2011

Re: Error 415 when updating contact lists

Hi,

 

I'm not sure what program you're using to build your XML here, but could you post the XML that this produces?

 

Best Regards,

Shannon W.

API Support Specialist