Jul 31, 2020 6:59 AM
Hi together,
we are facing an issue with the search / filter api (V3) on the contacts object.
In our integration scenario we need to get a contact by its email address. If there is no contact found, we create a new one with this specific email address.
This procedure works as long as the email address is not a secondary email address of any contact.
If the email address is a secondary one, the search api can't find the contact. But if we try to create a new contact with this email address it results in an status code 409 (Conflict).
Is there any way to get a contact by its secondary email address?
Thanks in advance!
Here are some screenshots:
Existing Contact :
Create Contact:
Search Contact:
Solved! Go to Solution.
Aug 4, 2020 3:40 PM
Hey @MGO ,
Thanks for reaching out. Using the EQ operator when searching on the 'email' property won't return contacts based on their secondary emails; it'll only return contacts with a primary email that matches the search term.
What you might consider doing instead (or in combination) is using the CONTAINS_TOKEN operator and searching the 'hs_additional_emails' field. Here's an example body that should do the trick:
{ "filterGroups": [ { "filters": [ { "value": "((email))", "propertyName": "hs_additional_emails", "operator": "CONTAINS_TOKEN" } ] }, { "filters": [ { "value": "((email))", "propertyName": "email", "operator": "EQ" } ] } ] }
Aug 4, 2020 3:40 PM
Hey @MGO ,
Thanks for reaching out. Using the EQ operator when searching on the 'email' property won't return contacts based on their secondary emails; it'll only return contacts with a primary email that matches the search term.
What you might consider doing instead (or in combination) is using the CONTAINS_TOKEN operator and searching the 'hs_additional_emails' field. Here's an example body that should do the trick:
{ "filterGroups": [ { "filters": [ { "value": "((email))", "propertyName": "hs_additional_emails", "operator": "CONTAINS_TOKEN" } ] }, { "filters": [ { "value": "((email))", "propertyName": "email", "operator": "EQ" } ] } ] }