The remote server returned an error: (409) Conflict.

 I haven't been able to finger what I am doing wrong on this one.  After a PUT to update a contact, I always get the response 409 Conflict.
 This is what i am PUTing (slightly modified site names)
 

<entry xmlns="http://www.w3.org/2005/Atom">
<id>https://api.constantcontact.com/ws/customers/accountname/contacts/828</id>
<title type="text">Contact: ddddddddd@asdf.com</title>
<updated>2008-07-23T14:21:06.407Z</updated>
<author>asdf</author>
<content type="application/vnd.ctct+xml">
<Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="https://api.constantcontact.com/ws/customers/accounbtname/contacts/828">
<EmailAddress>ddddddddd@asdf.com</EmailAddress>
<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
<ContactLists></ContactLists>
</Contact>
</content>
</entry>
 
 
And that is built by this code:
 
 

StringBuilder reqString = new StringBuilder();

reqString.Append( "<entry xmlns=\"http://www.w3.org/2005/Atom\">" );

reqString.Append( "<id>https://api.constantcontact.com/ws/customers/" + cci.APILogin + "/contacts/" + link + "</id>" );

reqString.Append( "<title type=\"text\">Contact: " + cci.Email + "</title>" );

reqString.Append( "<updated>2008-07-23T14:21:06.407Z</updated>" );

reqString.Append( "<author>asdf</author>" );

reqString.Append( "<content type=\"application/vnd.ctct+xml\">" );

reqString.Append( "<Contact xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"https://api.constantcontact.com/ws/customers/" + cci.APILogin + "/contacts/" + link + "\">" );

reqString.Append( "<EmailAddress>" + cci.Email.ToLower() + "</EmailAddress>" );

reqString.Append( "<OptInSource>ACTION_BY_CUSTOMER</OptInSource>" );

reqString.Append( "<ContactLists>" );

reqString.Append( "</ContactLists>" );

reqString.Append( "</Contact>" );

reqString.Append( "</content>" );

reqString.Append( "</entry>" );

byte[] buffer = Encoding.UTF8.GetBytes( reqString.ToString() );

HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create( "https://api.constantcontact.com/ws/customers/" + cci.APILogin + "/contacts/" + link );

WebReq.Credentials = new NetworkCredential( cci.APIKey + "%" + cci.APILogin, cci.APIPassword );

WebReq.Method = "PUT";

WebReq.ContentType = "application/atom+xml";

WebReq.ContentLength = buffer.Length;

Stream PostData = WebReq.GetRequestStream();

PostData.Write( buffer, 0, buffer.Length );

PostData.Close();
 

Have you tried running your

Have you tried running your XML through the REST Client to see why it is returning a 409 code?  In the return XML it typically will give you a reason for the issue.  Also, by using the REST Client you can change your XML easily until you find the cause of the conflict.
 
You can find the REST Client here.

Dave B Support Engineer, Constant Contact

 The 409 returns no content

 The 409 returns no content in the body.  Using the RESTClient, all I get is the 409 confilict with no more information.

Any resolution for this problem?

I am also experiencing this same problem with the 409.  It only happens when a contact already exists in the Constant Contact contact list (even if they have been deleted), and they attempt to add themselves to an additional list.
 
Any help would be greatly appreciated.
 
Thanks,
Steve

 no resoultion yet.

 no resoultion yet.

A 409 will always be returned

A 409 will always be returned if the XML posted attempts to create or change a contact that would put it in conflict with another existing contact.  This is intended behavior.  If you have a specific example in which a contact can not be updated, please email the exact XML you are posting as well as any other information (URI, Username, etc) to our webservices support team and we will look into the specific example.  
 
Please keep in mind, this is typically a simple XML issue where there is a small error in your XML.  Also, Deleteing a contact does not delete it from your Constant Contact database.  The Delete operation moves a contact to your Do Not Mail list.  To add them back to an active list, they must request to be added and an Update (PUT) will need to be used rather than a Create (POST).

Dave B Support Engineer, Constant Contact

re: 409 when existing contact has opted out

Two points to clarify here:
1. If a contact already exists, then you must *update* that existing contact (ie. use an HTTP PUT).  Attempting to create (ie. use an HTTP POST) on an existing contact will result in a 409/conflict response.
2. If a contact already exists, and has 'opted out' (aka unsubscribed, aka "deleted"), then the update request MUST be initiated by the contact, and the PUT request must reflect this by using an ACTION_BY_CONTACT OptInSource.  See the 
Opting-in a Contact
section at the bottom of this page for more information.
Thanks,

Tom Mignosa, Product Manager, Constant Contact