How to easily add email to contact via API?

I need to add emails to contacts. But I wasn't able to find out how to do it in a convenient way.

Now when I want to add an email address to a contact, I have to call three endpoints.

1 - I need to call POST /EmailAddresses to get the email address's ID.

2 - I need to call GET /Contacts/<id> to get email addresses already attached to the contact to use them in PUT so they won't get deleted.

and finally 3 - PUT /Contacts with the email array containing all email addresses along with the new one.

This seems a little bit odd to do just to add an email address to a contact. Isn't there something simpler?

Something like /POST /Contacts/link/emailAddresses or whatever I may be missing?

Thanks

Parents
  • When you're creating a contact (ie you know there's no other email address) you can use the shortcut email1, which will create a single primary email address for your contact.  Otherwise, you need to get your contact to make sure the email address isn't already present on the contact, if it isn't, check if the email address exists.  If it does, then you can just relate the contact to the email, otherwise you'd have to create the email, and  then associate with the contact.  If this is something you do a lot, I'd create an endpoint, which you pass the contact id and email address into (and do all the following with the bean instead of over multiple external http calls.

Reply
  • When you're creating a contact (ie you know there's no other email address) you can use the shortcut email1, which will create a single primary email address for your contact.  Otherwise, you need to get your contact to make sure the email address isn't already present on the contact, if it isn't, check if the email address exists.  If it does, then you can just relate the contact to the email, otherwise you'd have to create the email, and  then associate with the contact.  If this is something you do a lot, I'd create an endpoint, which you pass the contact id and email address into (and do all the following with the bean instead of over multiple external http calls.

Children