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.

Error 400 when adding multiple contacts to a list

Occasional Participant

Error 400 when adding multiple contacts to a list


I'm trying to add multiple contacts to a list, and for that i had used the documentation found here: (creating an add contacts/remove contacts activity)

i had used this code but the server send an error 400 message...



protected function doServerAddContactsToListCall($request,$parameter,$type="POST")


            $ch = curl_init();

            $request = str_replace('http://', 'https://', $request);

            // Convert id URI to BASIC compliant

            curl_setopt($ch, CURLOPT_URL, $request);

            curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");

            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

            curl_setopt($ch, CURLOPT_USERPWD, $this->requestLogin);

            # curl_setopt ($ch, CURLOPT_FOLLOWLOCATION  ,1);

            curl_setopt($ch, CURLOPT_HEADER, 0);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

            curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/x-www-form-urlencoded", 'Content-Length: ' . strlen($parameter)));

            curl_setopt($ch, CURLOPT_FAILONERROR, 1);

            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);     

            curl_setopt($ch, CURLOPT_POST, 1);

            curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);              

           $emessage = curl_exec($ch);

           if ($this->curl_debug) {   echo $error = curl_error($ch);   }


           return $emessage;


where $request is : ""

$parameter is : "" where 119/2010-10-07 is the name of the list (that i allready have)

and $type is :"POST"

I made the conversion to hexa for characters like '/' , '&' , ':', '@', '?', '=' and ';' here :


$search  = array('@', ':', '/', ';', '?', '&', '=');

$replace = array('%40', '%3A', '%2F', '%3B', '%3F', '%26', '%3D');          

$string = str_replace($search, $replace, $string);          

where the result of string variable is the same as $parameter.







Occasional Advisor

Error 400


After looking at your code, it appears the issue is the last portion of your $parameter. In your example, you use the list name, "119/2010/10/07", as the target list. Our API, however, requires that you designate your target list by list ID (i.e. for your general interests list, etc.) and not by list name.

More information on how to retrieve list information, including list ID, can be found at the following link:

Andrew T

Support Engineer, Constant Contact

Occasional Participant

retrieving list by list name

 is there a way to retrieve a list by using the list name instead of list id? Thanks

Occasional Participant

 nevermind...i understand how

 nevermind...i understand how to do this, but still i have a problem error 400 when trying to add contacts to a list.

Here is the string that i'm sending in a post variable:




Re: nevermind...i understand how

There were a few modifications I needed to make in order to make this work. The exact string that worked for me is:





1. the '@' symbol needs to be URL encoded as %40


2. Your lists look like you are attempting to add the contact to two lists, but it does not look like the first one has an actual list id being specified, and the second one is not URL encoded. You currently have:



I needed to modify this to be:




After you make these two small modifications, this should successfully create an add contacts activity in your account. I hope this helps. Please let me know if you have any questions or concerns regarding this issue.

David J

Occasional Participant

same problem...Error 400

 Now i have the same error 400 when trying to add contacts to a list i have created before.

This is what the function returns:


%2Fws%2Fcustomers%2Fvali_osf%2Flists%2F32-----The requested URL returned error: 400

In this case i try to add 2 contacts (that allready exists in "General Interest" list) and to the list that has id='32'.

Can you please give me a feedback what i did wrong. Thanks.


Re: same problem...Error 400

Your request body successfully created an activity in my account, but it added and rather than to list id 32. The exact data I posted was:



It would seem that the issue lies outside of the request body. Would you be able to reply to this post with the code you are using to make this request? If you would rather send a private email to our webservices support team you can certainly do that instead.


David J

Occasional Participant

found the problem...

 Meanwhile I found the problem. Consider this topic closed. Thanks.

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