APIs & Integrations

PMalaquias
Member

Function to search for associated objects does not work

Hello guys, how are you? I am carrying out an API integration and associated a company with an event
(1 event (which is a customObject) can have several companies)
The association worked correctly and I can view it through Hubspot, but I am not able to search for this data in the API, when I click on the list of associations it only returns the ID's of the associated data, I need you to bring me all the company and event data, how do I do it? that?

0 Upvotes
3 Replies 3
Teun
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Function to search for associated objects does not work

Hi @PMalaquias ,

 

If I understood correctly, you want to retrieve the event and all of it's associated companies including it's properties.

This isn't possible using the regular API. If you make a GET request to `/crm/v3/objects/<object>/{recordId}?associations=companies` you can retrieve the ID's of the associated companies, when you have those, you can retrieve those companies through a second API call.

If you use GraphQL, you can retrieve all that information in a single API call. 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
PMalaquias
Member

Function to search for associated objects does not work

I'm trying to use GraphQL but I keep getting the following error:

Status code 403 {"status":"error","message":"This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes.","correlationId":"0f925c51-9062-415c-81e3-a39fd21c2044","errors":[{"message":"All of the following scopes are required.","context":{"requiredScopes":["collector.graphql_query.execute"]}}],"links":{"scopes":"https://developers.hubspot.com/scopes"},"category":"MISSING_SCOPES"}

However, I have already added this scope to my key and it continues to display the error.
PMalaquias_0-1726787250632.png

 

0 Upvotes
dsmarion
Top Contributor | Gold Partner
Top Contributor | Gold Partner

Function to search for associated objects does not work

Use the company id you get back to call the Read endpoint for the company.  https://developers.hubspot.com/beta-docs/reference/api/crm/objects/companies#get-%2Fcrm%2Fv3%2Fobjec...  

dsmarion_0-1726744054182.png

You can also read in batches to get more than one back with a single call  

dsmarion_1-1726744165183.png

 

Scott Marion
Senior Developer @ Thread Connected Marketing
0 Upvotes