We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

missing feature --- Create new Contact via API call

MikeM4003
Regular Participant

missing feature --- Create new Contact via API call

Hello Support community,

I am currently working on the Creating campaign/contact list and adding contacts to the contact list.

Looking at your documentation, I see that there is no API call for creating a new contact in ConstantContact. Is this assumption correct, if yes, how do I go around this problem. I am trying to automate creating a campaign and adding contacts to the campaign from Salesforce, but stuck at this point.

Regards,
Mihir

3 REPLIES 3
Shannon_W
Employee

Hi Mihir,

 

You can most definitely create a new contact using our API.  Here is a link to the page that describes how to add a contact.

 

Best Regards,

Shannon W.

API Support Specialist

MikeM4003
Regular Participant

Thanks again Shannon.

 

I am now having trouble adding a contact to list. Below is the XML  I am using in the POST HTTP call.

 

 

<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/<username>/contacts/2</id>
<title type="text">Contact: example1@gmail.com</title>
<updated>2012-04-25T19:29:06.096Z</updated>
<author> </author>
<content type="application/vnd.ctct+xml">
<Contact xmlns=" http://ws.constantcontact.com/ns/1.0/" id=" http://api.constantcontact.com/ws/customers/<username>/contacts/2">
<EmailAddress>example1@gmail.com</EmailAddress>
<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/<username>/lists/2"></ContactList>
<ContactList id=" http://api.constantcontact.com/ws/customers/<username>/lists/21"></ContactList>
<ContactList id=" http://api.constantcontact.com/ws/customers/<username>/lists/23"></ContactList>
</ContactLists>
</Contact>
</content>
</entry>

 

Error: 415: Unsupported Media Type.

 

I tried changing the Content type to either of following, but did not help

application/vnd.ctct+xml

application/atom+xml 

 

Hi Mihir,

 

The XML looks good with the small exception of one thing that I noticed was also wrong (and that I subsequently corrected) in our documentation.  The Contact node has a space before the URL--you'll want to remove that space also.

 

You want to be doing a PUT and not a POST, however.  Adding a contact to a list using this XML is only available for existing contacts, and whenever you do an update to a contact, you use the PUT method.  For new contacts, reference the XML on this page.  

 

You should be setting the Content type in the header to application/atom+xml (but leave the XML as it is).

 

Best Regards,

Shannon W.

API Support Specialist

Developer Portal

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

Visit Page