Deleting Street Addresses

SOLVED
Go to solution
user558013
Campaign Collaborator
0 Votes

Hi,

 

I'm trying to figure out how to delete obsolete contact street addresses through the API.

 

Example:

  • POST /contacts John Smith with street addresses 123 Linden Ave and 456 Cherry Blossom Ln.
  • A year later, John no longer needs to receive mail at 456 Cherry Blossom Ln.
  • We need to remove that address from his street addresses.

The documentation for PUT /contacts/{contact_id} says:

 

Add or change any of the subresources by including them in the PUT request payload. Omitted subresources are not overwritten with null.

 

How can we get rid of the old address?

1 ACCEPTED SOLUTION
user558013
Campaign Collaborator
0 Votes

Okay, I think I have my answer. In my testing:

 

  • Only the addresses in the street_addresses array are preserved for the contact.
  • All addresses not in that array are removed from the contact.

 

Example:

 

  • POST /contacts John Smith with street addresses 123 Linden Ave and 456 Cherry Blossom Ln.
  • PUT /contacts/{contact_id} with John Smith's contact ID and only street address 456 Cherry Blossom Ln.
  • GET /contacts/{contact_id}?include=street_addresses with John Smith's contact ID.
  • Only 456 Cherry Blossom Ln is in the list of street addresses.

 

The documentation, and Courtney's helpful answer, made it clear that omitting street_addresses altogether would preserve all existing street addresses for that contact, making no changes. But I wasn't sure what would happen if street_addresses were included but the only item in the array were a new address. Would the new address be added to the contact's list of addresses, or would it replace them? I.e., is street_addresses incremental or full?

 

Based on my testing, street_addresses seems to do a full replacement of any existing addresses.

 

Constant Contact team or anyone else who stumbles upon this, please correct me if I'm wrong.

View solution in original post

4 REPLIES 4
user558013
Campaign Collaborator
0 Votes

Anyone here?

Courtney_E
Moderator
0 Votes

Hello user558013,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

You can use this flow to update your contacts which incorporates two contact endpoints:

 

Step 1: Get the existing contact data using the "email" query parameter to search for a contact using a specific email address.

 

GET Contacts Collection

https://v3.developer.constantcontact.com/api_reference/index.html#!/Contacts/getContacts 

 

Step 2: Append/modify the returned data (such as removing the physical address in question) and update the schema of the response body from the previous call so that it is correct for the request body when calling PUT /contacts.

 

When you update a contact using a PUT, all properties are updated, overwriting all existing property values. Any properties left blank or not included in the PUT will be overwritten with a null/blank value.

 

PUT (update) a Contact

https://v3.developer.constantcontact.com/api_reference/index.html#!/Contacts/putContact 

 

Please have a look and let us know if you have any other questions!

 

You can also reach our team directly/securely via email at webservices@constantcontact.com and reference case #33082865


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
user558013
Campaign Collaborator
0 Votes

Hi Courtney,

 

Thanks for the reply!

 

I think that makes sense.

 

Do I have this right:

 

  • If we omit street_addresses from our PUT request: The contact's street addresses will not change.
  • If we include street_addresses in our PUT request: The contact's street addresses will be updated to exactly match the contents of the array. Any street addresses not in the array will be deleted from the contact's street addresses.

So, in my example, we could delete "456 Cherry Blossom Ln" from John Smith's street addresses like this:

 

"street_addresses": [{"kind": "home", "street": "123 Linden Ave", "city" ... }]

 

I.e., we only include "123 Linden Ave" in the street addresses array. "456 Cherry Blossom Ln" isn't there, so it's deleted.

 

To rephrase what I have above, my understanding is:

 

  • "street_addresses" property is missing from ContactPutRequest: No changes are made to the contact's street addresses
  • "street_addresses" property is an array in ContactPutRequest: The contact's street addresses will be changed to exactly match the contents of the array, deleting any existing street addresses for that contact that are not in the array

 

Is that right?

 

Eric

user558013
Campaign Collaborator
0 Votes

Okay, I think I have my answer. In my testing:

 

  • Only the addresses in the street_addresses array are preserved for the contact.
  • All addresses not in that array are removed from the contact.

 

Example:

 

  • POST /contacts John Smith with street addresses 123 Linden Ave and 456 Cherry Blossom Ln.
  • PUT /contacts/{contact_id} with John Smith's contact ID and only street address 456 Cherry Blossom Ln.
  • GET /contacts/{contact_id}?include=street_addresses with John Smith's contact ID.
  • Only 456 Cherry Blossom Ln is in the list of street addresses.

 

The documentation, and Courtney's helpful answer, made it clear that omitting street_addresses altogether would preserve all existing street addresses for that contact, making no changes. But I wasn't sure what would happen if street_addresses were included but the only item in the array were a new address. Would the new address be added to the contact's list of addresses, or would it replace them? I.e., is street_addresses incremental or full?

 

Based on my testing, street_addresses seems to do a full replacement of any existing addresses.

 

Constant Contact team or anyone else who stumbles upon this, please correct me if I'm wrong.

Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up