Adding Contact To List

Highlighted
Occasional Contributor

Adding Contact To List

I am adding a contact to a list using XML.

 

First I tried getting the contact's information and adding the <ContactList> node to the XML under the <ContactLists> node with the ID of the list I am adding it to:

 

<ContactList id="http://api.constantcontact.com/ws/customers/[username]/lists/9" />

 

This returned a 204 status but the contact was not added to the list.

 

The cointact is already in list ID 1 and looking at the Contact data I noticed that (contrary to the documentation) there is an OptInSource node under the <ContactList> node for list 1. So I added an <OptInSource> node under the <ContactList> and tried it again:

 

<ContactList xmlns="" id="http://api.constantcontact.com/ws/customers/[username]/lists/9">
<OptInSource>ACTION_BY_CONTACT</OptInSource>
</ContactList>

 

[username] is properly URL encoded.

 

Still returned a 204 status but the contact is not in the list.

 

What am I doing wrong?

 

Thanks!

Malcolm

3 REPLIES 3
Highlighted
CTCT Employee

Re: Adding Contact To List

Hi Malcolm,

 

After getting the XML, you are sending it back with an HTTP PUT?  Also, is it possible for you to give us the full XML that you are sending over in the put call?  I can try it on my end to see what is happening.

 

How are you getting the new list id?  Are you getting it by pulling the list URI in the API, or are you getting it from the user interface?  If I get the XML and cannot recreate your issue, I may also need your username and the email address you are trying to update, to see what is going on in the back end.  You can email those here.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Highlighted
Occasional Contributor

Re: Adding Contact To List

Benjamin:

 

Thanks! I am emailing.

 

Malcolm

Highlighted
Occasional Contributor

Re: Adding Contact To List

Problem solved.

 

And just in case anyone else has run into this, it was the xmlns="" attribute in the <ContactList> node of the new list that was causing the problem. Once that was removed, the contact was added.

 

Malcolm

Developer Portal

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

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured