The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

missing feature --- Create new Contact via API call

Highlighted
Occasional Contributor

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
Highlighted
Employee

Re: missing feature --- Create new Contact via API call

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

Highlighted
Occasional Contributor

Re: missing feature --- Create new Contact via API call

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 

 

Highlighted
Employee

Re: missing feature --- Create new Contact via API call

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

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured