APIs & Integrations

MGO
参加者

Search Contacts for Secondary Mail

解決

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 :

ExistingContact.png
Create Contact:

CreateContact.png

Search Contact: 

SearchContact.png

1件の承認済みベストアンサー
Derek_Gervais
解決策
元HubSpot社員
元HubSpot社員

Search Contacts for Secondary Mail

解決

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"
        }
      ]
    }
  ]
}

元の投稿で解決策を見る

1件の返信
Derek_Gervais
解決策
元HubSpot社員
元HubSpot社員

Search Contacts for Secondary Mail

解決

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"
        }
      ]
    }
  ]
}