APIs & Integrations

AB35
Member

Search endpoint filter enumeration properties?

Hello!
I am trying to retrieve all contacts that have a specific set of vids (IDs - canonical or otherwise) via the Search Endpoint and the 'hs_all_contact_vids' property:

        {
            "updatedAt": "2022-05-27T20:57:17.998Z",
            "createdAt": "2019-08-06T02:41:10.764Z",
            "name": "hs_all_contact_vids",
            "label": "All vids for a contact",
            "type": "enumeration",
            "fieldType": "select",
            "description": "A set of all vids, canonical or otherwise, for a contact",
            "groupName": "contactinformation",
            "options": [],
            "displayOrder": -1,
            "calculated": true,
            "externalOptions": false,
            "hasUniqueValue": false,
            "hidden": true,
            "hubspotDefined": true,
            "modificationMetadata": {
                "archivable": true,
                "readOnlyDefinition": true,
                "readOnlyValue": true
            },
            "formField": false
        }

 When retrieving data via "/crm/v4/objects/contacs", as can be seen below 'hs_all_contact_vids' si returned as '201;251'

        {
            "id": "251",
            "properties": {
                "createdate": "2022-09-22T04:02:01.807Z",
                "firstname": "John2",
                "hs_all_contact_vids": "201;251",
                "hs_object_id": "251",
                "lastmodifieddate": "2023-03-27T15:53:36.095Z"
            },
            "createdAt": "2022-09-22T04:02:01.807Z",
            "updatedAt": "2023-03-27T15:53:36.095Z",
            "archived": false
        }

  However, this query returns no resulsts:

{
  "limit": 1,
  "after": 0,
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "hs_all_contact_vids",
          "operator": "EQ",
          "value": "201;251"
        }
      ]
    }
  ],
  "properties": [
    "id"
  ]
}

Changing the above to IN and values resolves the issue:

{
  "limit": 100,
  "after": 0,
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "hs_all_contact_vids",
          "operator": "IN",
          "values": ["201","251"]
        }
      ]
    }
  ],
  "properties": [
    "firstname",
    "hs_all_contact_vids"
  ]
}

But why does this occurr? Why does IN work and not EQ? Is there some API usage rule I am missing? Any information on this behavior and how to generally handle it would be appreciated.

0 Upvotes
2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

Search endpoint filter enumeration properties?

Hey, @AB35 👋 Thanks for reaching out! This is a great question. The Search API documentation on Search Operators doesn't specify whether the EQ filter will accept multiple values or multiple values as an array. 

Questions:

  • Have you tried using an array in your request using EQ? 
    {
      "limit": 1,
      "after": 0,
      "filterGroups": [
        {
          "filters": [
            {
              "propertyName": "hs_all_contact_vids",
              "operator": "EQ",
              "value": ["201;251"]
            }
          ]
        }
      ],
      "properties": [
        "id"
      ]
    }​
  • For your use case, are the contacts who have multiple values for  “hs_all_contact_vids” contacts who've been merged? So, I can try to reproduce on my end if needed. 

I understand why the EQ operator makes sense in this case. And I want to clarify if we can leverage it this way, e.g. matching multiple specific values.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
AB35
Member

Search endpoint filter enumeration properties?

Hi,
Thank you very much for the reply.
I do not know if this behavior is expected, but I tested EQ with only a single value, and it returns the entity in the result.

 

 

{
  "limit": 100,
  "after": 0,
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "hs_all_contact_vids",
          "operator": "EQ",
          "value": "201"
        }
      ]
    }
  ],
  "properties": [
    "id",
    "hs_all_contact_vids",
    "testenumeration"
  ]
}

 

 

 

 

 

{
    "total": 1,
    "results": [
        {
            "id": "251",
            "properties": {
                "createdate": "2022-09-22T04:02:01.807Z",
                "hs_all_contact_vids": "201;251",
                "hs_object_id": "251",
                "lastmodifieddate": "2023-03-28T08:34:35.433Z",
                "testenumeration": "Option1;Option2;Option3;Option4;Option5Option"
            },
            "createdAt": "2022-09-22T04:02:01.807Z",
            "updatedAt": "2023-03-28T08:34:35.433Z",
            "archived": false
        }
    ]
}

 

 

 I also tested the following, but none of them worked:

 

 

          "value": ["201;251"] -> Invalid input JSON 
          "value": ["201"] -> Invalid input JSON 
          "values": ["201"] -> operator EQ requires a value

 

 


> For your use case, are the contacts who have multiple values for “hs_all_contact_vids” contacts who've been merged?
Yes. The problem can also be reproduced if using a custom property that allows selecting multiple options (Multiple checkboxes).

 

 

 

{
  "limit": 100,
  "after": 0,
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "testenumeration",
          "operator": "EQ",
          "value": "Option1"
        }
      ]
    }
  ],
  "properties": [
    "id",
    "hs_all_contact_vids",
    "testenumeration"
  ]
}
{
    "total": 2,
    "results": [
        {
            "id": "151",
            "properties": {
                "createdate": "2022-09-20T12:29:20.903Z",
                "hs_all_contact_vids": "151",
                "hs_object_id": "151",
                "lastmodifieddate": "2023-03-28T09:11:00.233Z",
                "testenumeration": "Option1"
            },
            "createdAt": "2022-09-20T12:29:20.903Z",
            "updatedAt": "2023-03-28T09:11:00.233Z",
            "archived": false
        },
        {
            "id": "251",
            "properties": {
                "createdate": "2022-09-22T04:02:01.807Z",
                "hs_all_contact_vids": "201;251",
                "hs_object_id": "251",
                "lastmodifieddate": "2023-03-28T08:34:35.433Z",
                "testenumeration": "Option1;Option2;Option3;Option4;Option5Option"
            },
            "createdAt": "2022-09-22T04:02:01.807Z",
            "updatedAt": "2023-03-28T08:34:35.433Z",
            "archived": false
        }
    ]
}

 

 

It seems to me that the API is treating each value as a sub-field of its own even though GET returns them as one semicolon separated list. So, "EQ value" for enumeration types works like 'retrieve all records that have at least this value in that property'.

0 Upvotes