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.

Editing a contact's lists returns a 400 error

Highlighted
Regular Visitor

Editing a contact's lists returns a 400 error

I'm trying to edit a contact to add that contact to more than one list, when I use the editSubscriber method, I receive a 400 error. Sample code below:

 

$contact = $ccContactOBJ->getSubscriberDetails(urlencode(urldecode(trim($email))));
//get contact details for a specific email address.

if ($_SERVER['REMOTE_ADDR']=="AAA.BBB.CCC.DDD") { //only perform this for my IP since I'm testing.

echo "<pre>";
print_r($contact);
//show contact's details


$lists = $contact[lists];
$lists[]="http://api.constantcontact.com/ws/customers/XXXXXXXXXXXXX/lists/6";
print_r($lists);

//add new list value to existing [lists] element
$contact[lists] = $lists;

print_r($contact); //just checking the object structure still looks OK


if ($ccContactOBJ->editSubscriber($contact[id],$contact)) {//edit the contact

$contact2 = $ccContactOBJ->getSubscriberDetails(urlencode(urldecode(trim($email))));
print_r($contact2);
echo "</pre>";

}

}

 

I understand that the 400 error would imply malformed XML, but seeing as I'm re-using the same object structure that was obtained in the first place, I don't see how the error would be relevant.

 

Any ideas anyone?

1 REPLY 1
Highlighted
Employee

Re: Editing a contact's lists returns a 400 error

Hey Jennifer,

 

It appears that you are using our cc_class.php as a wrapper which it was not intended for.  You can find our wrapper under the code samples which should help resolve your issue.

 

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