APIs & Integrations

JNichel
Participant

Return Company (or id) from contacts search

SOLVE

Hi,

 

I'm doing a search for newly created contacts in Hubspot and have that part working fine.  However, as the title says, I'm having an issue  returning the company name and or id in those results.  Looking at the documentation for /crm/v3/objects/contacts/search  the example return data has:

 

 

"properties": {
        "company": "Biglytics",
        "createdate": "2019-10-30T03:30:17.883Z",

 

 

I found some posts such as Hubspot community post but the solution didn't work.  Can someone point out what I seem to be missing?

0 Upvotes
1 Accepted solution
weiliang_lee
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Return Company (or id) from contacts search

SOLVE

Hi there,

 

Unfortunately I don't think we can do a join statement like that via the API. The closest I can think of is to do 2 calls, then do a function to merge both JSON responses by their ID.

 

Question though: aside from performance, is there other considerations as to why you need the data returned in one API call?

 

Cheers

WL

View solution in original post

0 Upvotes
5 Replies 5
weiliang_lee
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Return Company (or id) from contacts search

SOLVE

Hi there!

 

Are you looking to "Get Companies By Contact ID"? If so, the Search endpoint is correct but you could use /crm/v3/objects/companies/search.

 

In your request body, do something like this:

{
  "filters": [
    {
      "propertyName": "associations.contact",
      "operator": "IN",
      "value": <your list of ids>
    }
  ]
}

 

Cheers
WL

 

 

0 Upvotes
JNichel
Participant

Return Company (or id) from contacts search

SOLVE

Hi,

 

Thank you for the reply.  Unfortunately, this is not quite what I'm trying to do.  Yes, my end result (that I'm hoping for) is to return the company with the newly created contact, but I was hoping to do it in one call.  For example, if I was to pull this info from a database, my query would look someting like this:

 

SELECT a.contact, b.company FROM contacts a LEFT JOIN companies b ON a.id = b.id WHERE a.createdate > timeOfMyChoosing

0 Upvotes
weiliang_lee
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Return Company (or id) from contacts search

SOLVE

Hi there,

 

Unfortunately I don't think we can do a join statement like that via the API. The closest I can think of is to do 2 calls, then do a function to merge both JSON responses by their ID.

 

Question though: aside from performance, is there other considerations as to why you need the data returned in one API call?

 

Cheers

WL

0 Upvotes
JNichel
Participant

Return Company (or id) from contacts search

SOLVE

WL,

 

Yeah, I've come to that conclusion that I'll have to make at least two calls for each contact.  I was hoping to do it in one call, not only for performance, but it would be cleaner/less code.

APrigent
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Return Company (or id) from contacts search

SOLVE

Hello @JNichel 

I am not a developer but I think my coworker @MBERARD can help for this one ! 

Alice