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.
Solved! Go to Solution.
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.
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
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 |
|
PLease let me know solution
thanks
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