Update Contact in .Net

Regular Participant

Update Contact in .Net

Is there a simple example of how to update a contact's data using .Net? I have the Contact ID and the URI https://api.constantcontact.com/ws/customers/{username}/contacts/{contact-id}


Do I need to write the entire XML content to the WebRequest stream? Just the "Contact" node?

3 REPLIES 3
Moderator

The easiest way to update a contact, especially in .NET, is to run a GET on your contact, load it into an XML structure (such as XmlDocument in .NET) and modify/update information.  You can than convert this back to an XML string (such as the OuterXml property) and send it back to us.  This is the easiest method I've found in my .NET work.

Dave Berard
Senior Product Manager, Constant Contact
Regular Participant

Thanks for the info Dave,


Is there a place on this site that defines what XML structures need to be passed in? I manged to get the Contact to update but now I'm having an error with ContactList. Is this the structure I want to send in for ContactList to update it?


 


<feed xmlns='http://www.w3.org/2005/Atom'>

  <id>2</id>

  <title type='text'>Contact Lists</title>

  <author>

    <name>Constant Contact</name>

  </author>

  <updated>2008-04-16T13:07:13.453Z</updated>

  <entry>

    <Name>Stuff</Name>

    <OptInDefault>False</OptInDefault>

    <ShortName>Default Customers</ShortName>

    <SortOrder>2</SortOrder>

    <OptInSource>ACTION_BY_CONTACT</OptInSource>

  </entry>

</feed>

Moderator

There is a full breakdown of the required and optional fields for each collection here.  We also have sample XML up there as well for all the different request types.


For example, here is the XML document for creating a list:


<entry xmlns="http://www.w3.org/2005/Atom">

  <id>data:,</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>A New List</Name>

      <SortOrder>99</SortOrder>

    </ContactList>

  </content>

</entry>

 

 

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page