Can anybody explain what does it mean "A Contact List is deleted by issuing an HTTP DELETE to the entry's URI"

Highlighted
Regular Participant

Can anybody explain what does it mean "A Contact List is deleted by issuing an HTTP DELETE to the entry's URI"

Hi I'm working with Contact Lists Collection API and I was just trying to figure out how I can update or delete a contact list but not able to understand the brief details provided in the API docs:

Updating a List
A Contact List is updated by issuing an HTTP PUT to the entry's URI. The PUT body must contain an Atom entry element with the changed content for the list.

Deleting a List
A Contact List is deleted by issuing an HTTP DELETE to the entry's URI. The call will return 204 No Content if it succeeds.

Can anybody help me out to understand how to issue HTTP PUT and HTTP DELETE to update or delete a Contact list.

Regards

Akhilesh
5 REPLIES 5
Highlighted
Developer

re: HTTP PUT / DELETE / POST etc

Hi Akhilesh -

The API is exposed as a set of URLs, custom to your account, which contain data for your account. There is a URL which returns the set of lists for your account, a URL which returns the set of Campaigns in your account and so on. To simply "read" data in your account, your program invokes an HTTP GET request (just like a browser would). To Update existing information, your program must issue an HTTP PUT request. To create new data, you ISSUE a POST command and to delete data you issue an HTTP DELETE request. You can invoke an HTTP request using different libraries, depending on your development environment.

There are basically four steps to perform when using the API:
1. Construct the required access control credentials which are needed to access the data. This is described, and then shown in a code example, in the API Authentication section of this page.

2. Determine the Specific URL which contains the data you want to update. These are the "URIs" referenced above. You can generally start at the top:
http://api.constantcontact.com/ws/customers/joesflowers/lists
will return the set of lists for the the "joesflowers" constant Contact account

3. Construct or modify an XML description of the object you want to create or modify. (In the case of a DELETE, no data is required). The XML structure for a list is shown here.

4. Using whatever library or approach you desire, invoke the HTTP (GET/PUT/POST/DELETE) with the header information (credentials and content-type) for the object you are modifying and the body (XML) you are sending.

This basic flow is shown in several examples on this site, including this PHP example, which uses CURL to invoke the HTTP calls.
Tom M
Group Product Manager – Content Editing
Constant Contact
Highlighted
Regular Participant

Thanks for the detailed reply.

Hi Tom, Thanks a ton for the detailed reply. I think it will help lot more people in the Forum. I was able to trace the issue of DELETE and PUT and am able to DELETE but still not able to update and rename lists as getting error 409 (conflict). :(

Regards

Akhilesh
Highlighted
Developer

re: 409 Conflict when updating lists

Akhilesh -
Can you post your xml and the URI you are posting the XML to? (You can remove/genericize your acccount name if you prefer) and I will take a look? I was able to gernate a 409 conflict when the <id> within my XML content was not consistent with the URI I was posting to. It is also worth noting that you cannot make changes to System defined lists such as ACTIVE and REMOVED (but these should give you a 400 error, not a 409).



Thanks,
Tom M
Group Product Manager – Content Editing
Constant Contact
Highlighted
Regular Participant

Here is the xml and URI I'm trying.

URI i'm posting to is:
http://api.constantcontact.com/ws/customers/username/lists/21

XML I'm trying is:

Set 1
"<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/username/lists/21</id>
<title/>
<author/>
<updated>2008-04-16</updated>
<content type="application/vnd.ctct+xml">
<ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">
<OptInDefault>false</OptInDefault>
<Name>New List - Update 21</Name>
<SortOrder>100</SortOrder>
</ContactList>
</content>
</entry>
"

Set 2
"<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/username/lists/21</id>
<title/>
<author/>
<updated>2008-04-16</updated>
<content type="application/vnd.ctct+xml" id="http://api.constantcontact.com/ws/customers/username/lists/21">
<ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">
<OptInDefault>false</OptInDefault>
<Name>New List - Update 21</Name>
<SortOrder>100</SortOrder>
</ContactList>
</content>
</entry>
"

Only diff. in both of these in the tag where I have added ID attribute to in the second set.
See if you could trace the issue with the XML.

Thanks & Regards

Akhilesh
PS: 50% times i'm getting error "The operation has timed out " :(
Highlighted
Regular Participant

List is being updated but not getting any status code

Hi Tom, List is being updated now with the same XML (Set1 posted above), but I'm not getting any status code in reply. Can you tell me what value we get in update and how we can capture same.

Regards

Akhilesh
Developer Portal

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

Visit Page

Register for our "Making Sense of Online Marketing for Retail" Webinar

Join us on Thursday, August 13th at 2pm ET for a free webinar where we'll discuss how to incorporate online marketing into your retail store.

Read More
Featured