APIs & Integrations


What is the right way to get all objects with all associations when association paging is required?

The v3 CRM Object API's List Objects endpoint allows you to request the inclusion of associations to one or more object types for each object found. Associations in this endpoint's responses are returned  as an array of objects that include an id and a type for each target object type, for example:



    "id": "18075504043",
    "type": "contact_to_company"



If an object has more than 100 associations to a given object type, then the associations key in the respose will include a paging key that contains a link to fetch more results, for example:



"paging": {
    "next": {
        "after": "MS01Ny0xODA3NTY3MDA1NQ%3D%3D",
        "link": "https://api.hubapi.com/crm/v3/objects/0-1/101/associations/0-2?portalId=44403636&after=MS01Ny0xODA3NTY3MDA1NQ%3D%3D"



However this endpoint doesn't return the rest of the associations as expected -- when I include the after key it just returns an empty results array, and when I don't include the after key (meaning I'm requesting all of the associations), it just returns a single one, when I'm sure there are over 100. Additionally, I believe I have seen documentation for this endpoint previously, but I can no longer find documentation for it.


This appears to constitute a bug in the CRM API, as the List Object response includes a link to get more associations, and that link does not work.


I see that the v4 Associations API has "the same" endpoint. However, there are two problems with using this endpoint to supplement the associations returned from the List Objects endpoint: 


  1. It returns associations in a different shape than those returned from the List Objects endpoint. The (v4) List Object Associations endpoint returns an array of objects that include the category, typeId and label keys, for example:


    "category": "USER_DEFINED",
    "typeId": 37,
    "label": "The user-facing name"



2. The after key from the List Objects response for the v3 endpoint is not compatible with the v4 endpoint:


    "status": "error",
    "message": "Given invalid after value MS01Ny0xODA3NTY3MDA1NQ==",
    "correlationId": "b57ada17-27f6-4502-9e29-7f43112bf67e",
    "context": {
        "after": [
    "category": "VALIDATION_ERROR"




That means that even if I can get over the differing shape of the response data, I still may end up storing duplicate associations.


What is the right way to efficiently get all objects of a particular type, and all their associations to particular object types, when there can be more than 100 associations from any single object to those of another type?

0 Replies 0

0 Replies

No replies on this post just yet

No one has replied to this post quite yet. Check back soon to see if someone has a solution, or submit your own reply if you know how to help! Karma is real.

Reply to post

Need help replying? Check out our Community Guidelines