Get all contacts search by company not returning ALL contacts

SOLVE
SJohnson53
Participant

Doing a search for contacts based on their `associatedcompanyid` is not returning ALL of the contacts. In the CRM there are 3 contacts on the company but only 2 are being returned via the API. Checking the missing contact I can see their `associatedcompanyid` is different - all 3 contacts are associated with multiple companies - is this expected? Is there a property that has all of the contacts associated company IDs?

 

My example request is:

curl --location --request POST 'https://api.hubapi.com/crm/v3/objects/contact/search?hapikey=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "filterGroups": [
        {
            "filters": [
                {
                    "operator": "EQ",
                    "propertyName": "associatedcompanyid",
                    "value": "6101168988"
                }
            ]
        }
    ],
    "properties": [
        "email",
    ],
    "limit": 30
}'
0 Upvotes
1 Accepted solution

Accepted Solutions
dennisedson
Solution
Community Manager

@SJohnson53 , if you are looking to get all contacts associated with a company, I would suggest employing the associations endpoint

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

3 Replies 3
dennisedson
Solution
Community Manager

@SJohnson53 , if you are looking to get all contacts associated with a company, I would suggest employing the associations endpoint

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content

View solution in original post

SJohnson53
Participant

Thanks - this worked - I got the associations then batch read the contacts - cheers!

webdew
Top Contributor | Diamond Partner

Hi @SJohnson53 ,

Kinldy use the below code:

curl --location --request POST 'https://api.hubapi.com/crm/v3/objects/contact/search?hapikey=API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"filterGroups": [
{
"filters": [
{
"operator": "EQ",
"propertyName": "associations.company",
"value": "<companyID>"
}
]
}
],
"properties": [
"email",
],
"limit": 30
}'


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

0 Upvotes