could somebody tell me how do I update a contact list name

Occasional Participant

could somebody tell me how do I update a contact list name

Hi guy:

   The only thing I want to do is Updating list's name . and here is my entry:

 

<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/joesflowers/lists/8</id>
<title />
<author />
<updated>2013-08-12</updated>
<content type="application/vnd.ctct+xml">
<ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">
<OptInDefault>false</OptInDefault>
<Name>newname</Name>
<SortOrder>99</SortOrder>
</ContactList>
</content>
</entry>

 

and I did a http put to   http://api.constantcontact.com/ws/customers/joesflowers/lists. it gives me (415)unsupported media type.

 

When I put it to http://api.constantcontact.com/ws/customers/joesflowers/lists/8.  it gives me (409) conflict

 

could some one give me  a detailed example please

6 REPLIES 6
Member

Hello,

 

After some testing, I found that the source of a 409 conflict on this PUT request is when the list ID does not match between the XML and the request URI. For example:

 

If the request URI is:

https://api.constantcontact.com/ws/customers/joesflowers/lists/8

 

And the XML has an ID of:

<id>http://api.constantcontact.com/ws/customers/joesflowers/lists/1</id>

 

You will receive an error 409 as the list IDs provided do not match (8 vs 1). However, once you correct the list ID so that it matches and the correct list ID is in both locations, then you should receive a HTTP 204 success.

 

Let me know if you have any difficulty with getting this to work!

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
Occasional Participant

Ok, but I still don't understand, How come XML has an ID of "1"?  In my entry I wrote 

<id>http://api.constantcontact.com/ws/customers/username/lists/8</id>

 

where does <id>http://api.constantcontact.com/ws/customers/joesflowers/lists/1</id> come from?

Hello,

 

In my example, I changed the IDs to show a case where you could run into an issue. What happens is if the ID in the URI and the ID in the XML do not match properly, then you will receive a 409 error. In my post I demonstrated a basic example of what that could look like.

 

If you're confident that this is not what's happening when you try to update a list via API, we should be able to provide more detailed help if you can paste the exact XML that you are sending here. However, if you do paste if here I would suggest replacing your username with a placeholder first.

 

Also it is worth mentioning that I have peronally tested this XML successfully(with my own username and list ID):

URI:
https://api.constantcontact.com/ws/customers/[username]/lists/1

XML:
<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/[username]/lists/1</id>
<title />
<author />
<updated>2013-08-12</updated>
<content type="application/vnd.ctct+xml">
<ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">
<OptInDefault>false</OptInDefault>
<Name>newname</Name>
<SortOrder>99</SortOrder>
</ContactList>
</content>
</entry>

 

Sincerely,

Elijah G.

API Support Specialist

 

Elijah G.
API Support Engineer
Occasional Participant

I really can't find the problem,
the exact XML is:


<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/[username]/lists/8</id>
<title/>
<author/>
<updated>2013-08-23</updated>
<content type="application/vnd.ctct+xml">
<ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">
<OptInDefault>false</OptInDefault>
<Name>newtest</Name>
<SortOrder>99</SortOrder>
</ContactList>
</content>
</entry>

 

and URL is :https://api.constantcontact.com/ws/customers/[username]/lists/8

 

My XML is a string, and I convert it to bytes before I put the data, And here is part of my code:

 

byte[] data = Encoding.ASCII.GetBytes(data);


HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Credentials = CreateCredentialCache(URL, authenticationData);

request.Method = WebRequestMethods.Http.Put;

request.ContentType = @"application/atom+xml";

request.PreAuthenticate = true;


request.ContentLength = data.Length;

// write data
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);

Stream responseStream = Stream.Null;
try
{

HttpWebResponse response = (HttpWebResponse)request.GetResponse();  // (409) conflict

Hello,

 

I have taken your code snippet and created a simple console application to test the logic. When I run this code snippet the application is able to update the list without any errors. At this point I suspect it may have something to do with how the XML data is handled before it is converted to bytes. Would it be possible for you to send the full code with the username and password omitted to webservices@constantcontact.com so that we can look into this further?

 

Additionally, please feel free to include any questions that you may have!

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
Occasional Participant

hi:

I have sent the information you need to you guys.

 

Thanks

Developer Portal

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

Visit Page