APIs & Integrations

gavina
Member

company property not returned when searching contacts

SOLVE

We've been using API Endpoint /contacts/v1/search/query to search our contacts, but despite the example in the documentation, the contact details do not contain the 'company' property with their associated company's name even when using '&property=company' specifically.

 

To then pull the company name we can then poll /companies/v2/companies/{companyid} as the contact details do include 'associatedcompanyid', but this is a time consuming operation and will use a lot of requests depending on the number of results.

I notice that it's possible do a batch request of contact IDs in a single request (/contacts/v1/contact/vids/batch), but not companies.

 

Is there a better way to get a given contact's associated company name when searching for contacts?

0 Upvotes
2 Accepted solutions
Willson
Solution
HubSpot Employee
HubSpot Employee

company property not returned when searching contacts

SOLVE

Hi @gavina 

 

The Company Name value is referred to as company when referencing the response from this endpoint. We should not be seeing 2 values i.e company_name and company as the former is the label for the internal value company

 

Also, you're correct with your observations, this is indeed a user-entered text field rather than an automated field that is associated to the Company Record.  

 

This means that if you're looking to identify the Associated Company you'll need to work with the associatedcompanyid and then fetch the name via the Get Company by ID endpoint found here.

 

 

Product Manager @ HubSpot

View solution in original post

0 Upvotes
gavina
Solution
Member

company property not returned when searching contacts

SOLVE

Thanks for the help Matthew.

I think what we'll do is programatically go through and add custom property for quick referencing a contact's company name or cache the companyid's name on our end to avoid an API call per search result once we're migrated over.

View solution in original post

7 Replies 7
Willson
HubSpot Employee
HubSpot Employee

company property not returned when searching contacts

SOLVE

Hi @gavina 

 

I've been unable to replicate this issue whereby the Company property is not returned when referencing the endpoint you've linked here:
https://developers.hubspot.com/docs/methods/contacts/search_contacts

 

Testing this out, i've used the following request URL:

https://api.hubapi.com/contacts/v1/search/query?q=hubspot&hapikey={{hapikey}}

This then returned the following:

{
    "query": "hubspot",
    "offset": 20,
    "has-more": true,
    "total": 146,
    "contacts": [
        {
            "vid": 1,
            "canonical-vid": 1,
            "merged-vids": [],
            "portal-id": 4940221,
            "is-contact": true,
            "profile-token": "AO_T-mN2KWx8wOkLlqmIcQy5LB0HYijKoEU5Xd6-a4Uaqf7SpI0ryn-PjWNlbsWhBwbMzWmBxeocXOuQwq4udBP0jtbacSVBE0P4w1NQ-N4Arki3UVM6WbL9iTav2mCzj97VqZJfIzhw",
            "profile-url": "https://app.hubspot.com/contacts/4940221/contact/1",

------------------------------- SNIPPET CUT --------------------------------------

"company": {
"value": "HubSpot"
}

As you can see, we should see the Company parameter returned in the response when making this request. 

 

If you're not seeing this can you provide me with an example request you're making where you're not seeing this being returned and we can take a look for you. 

 

Product Manager @ HubSpot
0 Upvotes
gavina
Member

company property not returned when searching contacts

SOLVE

Sure thing. Here's an example request:

// url "https://api.hubapi.com/contacts/v1/search/query"
// query

array:2 [
  "q" => "gavin"
  "hapikey" => "[redacted]"
]

// response array:5 [ "query" => "gavin" "offset" => 6 "has-more" => false "total" => 6 "contacts" => array:6 [ 0 => array:11 [ "vid" => [redacted] "canonical-vid" => [redacted] "merged-vids" => [] "portal-id" => [redacted] "is-contact" => true "profile-token" => "[redacted]" "profile-url" => "https://app.hubspot.com/contacts/[redacted]/contact/[redacted]" "properties" => array:62 [ "num_unique_conversion_events" => array:1 [ "value" => "0" ] "hs_analytics_revenue" => array:1 [ "value" => "0.0" ] "hs_email_quarantined" => array:1 [ "value" => "" ] "createdate" => array:1 [ "value" => "1570188450845" ] ------------------------------- SNIPPET CUT -------------------------------------- "hs_sales_email_last_replied" => array:1 [ "value" => "" ] "associatedcompanyid" => array:1 [ "value" => "[redacted]" ] "firstname" => array:1 [ "value" => "Gavin" ] "status_flag" => array:1 [ "value" => "Active" ] "contact_source" => array:1 [ "value" => "Data Clean Jan 2018" ] ] "form-submissions" => [] "identity-profiles" => array:1 [ 0 => array:4 [ "vid" => [redacted] "saved-at-timestamp" => 0 "deleted-changed-timestamp" => 0 "identities" => array:2 [ 0 => array:4 [ "type" => "EMAIL" "value" => "[redacted]" "timestamp" => 1570188450844 "is-primary" => true ] 1 => array:3 [ "type" => "LEAD_GUID" "value" => "[redacted]" "timestamp" => 1570188450856 ] ] ] ] "merge-audits" => [] ] ------------------------------- SNIPPET CUT -------------------------------------- ] ]

Could the way the data was uploaded originally have affected how this property works? It was done by a third party company who I'm waiting to hear back from regarding this.

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

company property not returned when searching contacts

SOLVE

Hi @gavina 

 

Would you be able to directly message me your Portal Id and the VID from this response so I can review this from my end?

 

Thanks

Product Manager @ HubSpot
0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

company property not returned when searching contacts

SOLVE

Hey @gavina 

 

I was able to fine the cause of this one for the contact we're referring to in this request. If we take a look at the Contact Record, we can see that the property Company Name is the property for the internal value company.

 

If we check this record, we can see that this value is empty and would return a null value hence why it is not being returned in the request. 

 

I've adde a value for this now and made the request again, you should now see that the company property is returned in your request. 

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
gavina
Member

company property not returned when searching contacts

SOLVE

Am I correct in thinking that the 'company' field is actually just a user-entered free text field, rather than the name of the company with the id in associatedcompanyid? 'company name' was also not in the returned set of properties.

If so it seems like a company lookup per returned contact will still be needed (or we programatically go through and set this field.

0 Upvotes
Willson
Solution
HubSpot Employee
HubSpot Employee

company property not returned when searching contacts

SOLVE

Hi @gavina 

 

The Company Name value is referred to as company when referencing the response from this endpoint. We should not be seeing 2 values i.e company_name and company as the former is the label for the internal value company

 

Also, you're correct with your observations, this is indeed a user-entered text field rather than an automated field that is associated to the Company Record.  

 

This means that if you're looking to identify the Associated Company you'll need to work with the associatedcompanyid and then fetch the name via the Get Company by ID endpoint found here.

 

 

Product Manager @ HubSpot
0 Upvotes
gavina
Solution
Member

company property not returned when searching contacts

SOLVE

Thanks for the help Matthew.

I think what we'll do is programatically go through and add custom property for quick referencing a contact's company name or cache the companyid's name on our end to avoid an API call per search result once we're migrated over.