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 adding contact to list

Highlighted
Occasional Contributor

Error adding contact to list

Hi,

 

I am trying to add a contact email to an existing list in CC.  I am using PHP with the wrapper provided by CC.  I have verified the variable being passed as the list ID as coming from the $ConstantContact->getLists(); call.

 

I currently get this error:

 

Constant Contact HTTP Request Exception: Error 400: The new contact must contain at least one valid ContactList

 

Code is:

 

$username = 'xxx';
$apiKey = 'xxx';
$consumerSecret = 'xxx';


$Datastore = new CTCTDataStore();


$sessionConsumer = array(
        'key' => 'xxx',
        'secret' => 'xxx',
        'username' => 'xxx'
    );
$Datastore->addUser($sessionConsumer);


$DatastoreUser = $Datastore->lookupUser($username);
   
if($DatastoreUser){
    $ConstantContact = new ConstantContact('oauth', $apiKey, $DatastoreUser['username'], $consumerSecret);    
}

$Contact = new Contact();
$Contact->emailAddress = "test@test.com";
$Contact->lists = "http://api.constantcontact.com/ws/customers/xxx/lists/1";
$NewContact = $ConstantContact->addContact($Contact);

4 REPLIES 4
Highlighted
Employee

Re: Error adding contact to list

Hey,

 

Try this :

 

$Contact->lists = array("http://api.constantcontact.com/ws/customers/xxx/lists/1");

 

Ryan Davis
Quality Engineer
Highlighted
Occasional Contributor

Re: Error adding contact to list

Thank you, that worked!

 

Highlighted
Member

Re: Error adding contact to list

Can somebody please update the documentation to reflect this so others don't spend time spinning their wheels like I did before coming the forum for the answer?

Highlighted
Employee

Re: Error adding contact to list

Hey Karen,

 

If you are referring to the documentation on github, I am currently in the process of rewriting it all. 

Ryan Davis
Quality Engineer
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