I am using constant contact API (https://api.constantcontact.com/v2/) with authorization type https://oauth2.constantcontact.com/oauth2/ for my site URL: http://www.labrada.com/lbc-homepage but we are getting this error for so many email ids:
Error Updating Contact
[error_key] => json.max.items.violation
[error_message] => #/email_addresses: 2 items were contained, but the maximum number of items allowed is 1.
I looked into the error and found that whenever an email id is already added in other lists i.e list1,list2 and we try to add it in some other list i.e list3.First we check for if email is already exist via API i.e
// check to see if a contact with the email addess already exists in the account
$response = $cc->getContactByEmail(ACCESS_TOKEN, ‘email@example.com’);
If it exists we execute the script :
$action = "Updating Contact";
$contact = $response->results;
$contact->first_name = ‘first_name';
$contact->last_name = 'last_name';
$returnContact = $cc->updateContact(ACCESS_TOKEN, $contact, true);
I get the error in above code where we update the contact.
Please help us to resolve the above error ASAP.IT'S URGENT.
I wanted to reach back out here and provide the information that I have provided via email as well. After researching this issue, it appears that a specific contact(and potentially some others) have some unusual data stored in their records which is causing our system to return multiple email addresses when only one should be returned. While we are investiating this, you could prevent this error by implementing code that forcefully limits the number of email addresses to 1.
Here is an example of how such code could work:
$contact->email_addresses = array_slice($contact->email_addresses, 0, 1);
If you have any questions, please feel free to reply here or to my email.
View API documentation, code samples, get your API key.