<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic What is the right way to get all objects with all associations when association paging is required? in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/What-is-the-right-way-to-get-all-objects-with-all-associations/m-p/900275#M70077</link>
    <description>&lt;P&gt;&lt;SPAN&gt;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&amp;nbsp; as an array of objects that include an &lt;STRONG&gt;id&lt;/STRONG&gt; and a &lt;STRONG&gt;type&lt;/STRONG&gt; for each target object type, for example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "id": "18075504043",
    "type": "contact_to_company"
},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If an object has more than 100 associations to a given object type, then the associations key in the respose will include a &lt;STRONG&gt;paging&lt;/STRONG&gt; key that contains a link to fetch more results, for example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;"paging": {
    "next": {
        "after": "MS01Ny0xODA3NTY3MDA1NQ%3D%3D",
        "link": "https://api.hubapi.com/crm/v3/objects/0-1/101/associations/0-2?portalId=44403636&amp;amp;after=MS01Ny0xODA3NTY3MDA1NQ%3D%3D"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However this endpoint doesn't return the rest of the associations as expected -- when I include the &lt;STRONG&gt;after&lt;/STRONG&gt; key it just returns an empty &lt;STRONG&gt;results&lt;/STRONG&gt; array, and when I don't include the &lt;STRONG&gt;after&lt;/STRONG&gt; 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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN&gt;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 &lt;STRONG&gt;category&lt;/STRONG&gt;, &lt;STRONG&gt;typeId&lt;/STRONG&gt; and &lt;STRONG&gt;label&lt;/STRONG&gt; keys, for example:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "category": "USER_DEFINED",
    "typeId": 37,
    "label": "The user-facing name"
},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;2. The &lt;STRONG&gt;after&lt;/STRONG&gt; key from the List Objects response for the v3 endpoint is not compatible with the v4 endpoint:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "status": "error",
    "message": "Given invalid after value MS01Ny0xODA3NTY3MDA1NQ==",
    "correlationId": "b57ada17-27f6-4502-9e29-7f43112bf67e",
    "context": {
        "after": [
            "Optional[MS01Ny0xODA3NTY3MDA1NQ==]"
        ]
    },
    "category": "VALIDATION_ERROR"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That means that even if I can get over the differing shape of the response data, I still may end up storing duplicate associations.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jan 2024 16:35:46 GMT</pubDate>
    <dc:creator>PCronin9</dc:creator>
    <dc:date>2024-01-03T16:35:46Z</dc:date>
    <item>
      <title>What is the right way to get all objects with all associations when association paging is required?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/What-is-the-right-way-to-get-all-objects-with-all-associations/m-p/900275#M70077</link>
      <description>&lt;P&gt;&lt;SPAN&gt;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&amp;nbsp; as an array of objects that include an &lt;STRONG&gt;id&lt;/STRONG&gt; and a &lt;STRONG&gt;type&lt;/STRONG&gt; for each target object type, for example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "id": "18075504043",
    "type": "contact_to_company"
},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If an object has more than 100 associations to a given object type, then the associations key in the respose will include a &lt;STRONG&gt;paging&lt;/STRONG&gt; key that contains a link to fetch more results, for example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;"paging": {
    "next": {
        "after": "MS01Ny0xODA3NTY3MDA1NQ%3D%3D",
        "link": "https://api.hubapi.com/crm/v3/objects/0-1/101/associations/0-2?portalId=44403636&amp;amp;after=MS01Ny0xODA3NTY3MDA1NQ%3D%3D"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However this endpoint doesn't return the rest of the associations as expected -- when I include the &lt;STRONG&gt;after&lt;/STRONG&gt; key it just returns an empty &lt;STRONG&gt;results&lt;/STRONG&gt; array, and when I don't include the &lt;STRONG&gt;after&lt;/STRONG&gt; 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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN&gt;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 &lt;STRONG&gt;category&lt;/STRONG&gt;, &lt;STRONG&gt;typeId&lt;/STRONG&gt; and &lt;STRONG&gt;label&lt;/STRONG&gt; keys, for example:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "category": "USER_DEFINED",
    "typeId": 37,
    "label": "The user-facing name"
},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;2. The &lt;STRONG&gt;after&lt;/STRONG&gt; key from the List Objects response for the v3 endpoint is not compatible with the v4 endpoint:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "status": "error",
    "message": "Given invalid after value MS01Ny0xODA3NTY3MDA1NQ==",
    "correlationId": "b57ada17-27f6-4502-9e29-7f43112bf67e",
    "context": {
        "after": [
            "Optional[MS01Ny0xODA3NTY3MDA1NQ==]"
        ]
    },
    "category": "VALIDATION_ERROR"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That means that even if I can get over the differing shape of the response data, I still may end up storing duplicate associations.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 16:35:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/What-is-the-right-way-to-get-all-objects-with-all-associations/m-p/900275#M70077</guid>
      <dc:creator>PCronin9</dc:creator>
      <dc:date>2024-01-03T16:35:46Z</dc:date>
    </item>
  </channel>
</rss>

