Contacts and the new API - How to do addressess?


Contacts and the new API - How to do addressess?

        $contact = $response->results[0];

        if(isset($_POST['name'])) {
        	$contact->first_name = $first_name;
        	$contact->last_name = $last_name;

        $address = new Address();      
        $address->city = $_POST['city'];
        $address->state_code = $_POST['state'];



        $returnContact = $cc->updateContact(ACCESS_TOKEN, $contact);

 This is basically the code from the example. I can't figure out how to update address information, though. We'd like to let folks put their city and state when they sign up. I'm getting the following error with this method. any help would be really appreicated!


 [error_key] => json.max.items.violation
            [error_message] => #/addresses: 3 items were contained, but the maximum number of items allowed is 2.

If you look at the $contact object you're getting in the first call, you'll likely find that the Contact in question already has two addresses (one home and one work).  We only support two addresses total, one of each type, so it looks like in this scenario you're adding a 3rd instead of updating one of the existing two, which is causing you to fail our JSON Schema validation for total number of items.

Dave Berard
Senior Product Manager, Constant Contact

Ah, thanks! That's so obvious I feel dumb for missing it.

Developer Portal

View API documentation, code samples, get your API key.

Visit Page