We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Editing a contact's lists returns a 400 error

JenniferB174
Participant

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

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