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:
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:
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:
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:
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?
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.