<?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 Re: Issues with CRM API V4 documentation for batch association deletion endpoint in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-CRM-API-V4-documentation-for-batch-association/m-p/810993#M65148</link>
    <description>&lt;P&gt;It looks like the Node.js code in the documentation of endpoint&amp;nbsp;&lt;STRONG&gt;/crm/v4/associations/{fromObjectType}/{toObjectType}/batch/archive&lt;/STRONG&gt; has been updated since this post was created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See the code as of 6/20/2023:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6-20-2023.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/93532iF731082D2A35DDFD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="6-20-2023.png" alt="6-20-2023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;And the code as of 6/22/2023:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6-22-2023.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/93531i4690D2B90D1EE72A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="6-22-2023.png" alt="6-22-2023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const apiResponse = await hubspotClient.crm.associations.v4.batchApi.archive(fromObjectType, toObjectType, BatchInputPublicAssociationMultiArchive);&lt;/LI-CODE&gt;&lt;P&gt;with the automatically generated input structure&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const BatchInputPublicAssociationMultiArchive = {
    "inputs": [
      {
        "_from": {
          "id": "81729"
        },
        "to": [
          {
            "id": "16004868498"
          }
        ]
      }
    ]
  };&lt;/LI-CODE&gt;&lt;P&gt;works as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marking as resolved!&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2023 20:29:21 GMT</pubDate>
    <dc:creator>BradySheridan</dc:creator>
    <dc:date>2023-06-22T20:29:21Z</dc:date>
    <item>
      <title>Issues with CRM API V4 documentation for batch association deletion endpoint</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-CRM-API-V4-documentation-for-batch-association/m-p/810390#M65106</link>
      <description>&lt;P&gt;I noticed two issues with the documentation for the CRM API (V4) endpoint&amp;nbsp;&lt;STRONG&gt;/crm/v4/associations/{fromObjectType}/{toObjectType}/batch/archive&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I send test API requests in-browser via the interactive documentation interface it works, but the Node.js code generated has multiple issues when migrated to a local Node environment.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Issue 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The Node.js code generated by the interactive docs contains an invalid, undefined reference on the Hubspot API client object. In particular, &lt;A href="https://19677425.cdnp1.hubspotusercontent-na1.net/hubfs/19677425/hubspot-zorse-prod/1-error-source-docs.png?Expires=1687454185&amp;amp;Signature=IUh-7xw5eaoRnSljwLCvGN1tZd4NsiDrGre0Sq0riS2nVo5geTK3lBsF59KPjMGZgSRL8dwa8C9pJN9AzO6aBSTayU0H7OcpxcrLxzfQfmKcQquIBu~s3g9oqDd1bpU5G~zCsCprGe9c0eqPP5VzZaMOmWiNLzTPQ6IiitEmW0gvh-ZaplQddO37NTvOctHuZuxVCpfupRX-vJg1dGMJS7S8ANPJUNWSTsnSrWSouKsGstoc0g9W-8XfwmXZ2NJoRaZyCXEK1F5~5LYrueIcshBetCCttpr3v76-mxsOWEXlOm59YGF8Dbk~NU5ABMSFTeh~RxcGxLBHpvLnBn~UJw__&amp;amp;Key-Pair-Id=APKAJDNICOKANPHVCSBQ" target="_blank" rel="noopener"&gt;this line of code&lt;/A&gt; throws the error visible &lt;A href="https://19677425.cdnp1.hubspotusercontent-na1.net/hubfs/19677425/hubspot-zorse-prod/1-error-1.png?Expires=1687454228&amp;amp;Signature=Qfx5keIcY-3sqSiRsU1givu6S~H0dSqowdnqpEs8JLbVTuoc6VKxIsDCG0xYFWB4EGmlluKXHXa8l2dsix1C0-jMwXau5TsXGoKVjkZ3Nq6eqXR8pYd3b8HtqCMpVpJZEX2eg5G1~JKjk9oiRAIknbFE177sbV3bSUuUux6lCxdTwz2vzcJjoQ10pWHr2oUZWZMg9tKSt7rqLuUzWHS5ZelDwhnwiTf2C7TBkNtplgFPvPlQ2fg0WjsIyVeX1kB7qt7FxwE1A5~q2TJjawLTnjRXRz23YuF3Wk27LAR6aT8g2tGzaDt5fEo5FUORvnxnNRRAwCBIEAEedVRqk9wlMQ__&amp;amp;Key-Pair-Id=APKAJDNICOKANPHVCSBQ" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&amp;nbsp;By removing&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;.batch.read&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from this line of code, the error is resolved. So the correct line reads&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const apiResponse = await hubspotClient.crm.associations.batchApi.archive(fromObjectType, toObjectType, BatchInputPublicAssociationMultiArchive);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Issue 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;After resolving issue 1, running the code returns an error from the API that reads&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Invalid input JSON on line 1, column 19. Some required fields were not set: [id]&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(full error &lt;A href="https://19677425.cdnp1.hubspotusercontent-na1.net/hubfs/19677425/hubspot-zorse-prod/2-error-1.png?Expires=1687454249&amp;amp;Signature=KcALJECsUq0qf9THg3qL8urdR~YcfqRVy5mAzMYesE2txCK-MQf9yj~6VC0s~O6KqaDnMpN99wFAN8HALoabSJe5kuJTu6jjiEZMPMSpguESSv89ssnkoFy2eGiF8TDXCqUPNbo9~q7GCGl4PyfrMSpaR0TuozAnhMOUa~2Doc~JWtIahOQwuAYKx0GGS19QsSYjY2HaSjtY4Ih~CxXmdPuGJ9CyxklzI0rLw6zboKjMWdFtiZw5gwmIQK0gMySJxK-slWql-I1VQGKCyvg76nyhL4ikXyXYNOPuCigfi0aLHeF79Oft8Jem8yF-QlTTjrJYeUAj1-e5vOKEVkW-wg__&amp;amp;Key-Pair-Id=APKAJDNICOKANPHVCSBQ" target="_blank" rel="noopener"&gt;here&lt;/A&gt;). Since this input was generated by the docs and is supposed to be its own "source of truth," it's difficult for me to determine what exactly is wrong with it. It appears that the input data structure expected by the API endpoint does not match the input data structure generated by the interactive docs (visible &lt;A href="https://19677425.cdnp1.hubspotusercontent-na1.net/hubfs/19677425/hubspot-zorse-prod/2-error-source-docs.png?Expires=1687454324&amp;amp;Signature=c~A-NL5uQJIOgrnTnn8eBPSpxiTl3FD465HPEu2h1WLFoxexgzPnV7498XIY3MGrx2GrqZPKGma6rWUEUKOV8N8Lull6S8l6eVP1t8VF8GV2KL-E~qmXKAqSq7tRVeMKi6dNNj9XNUtkg0AR~xK5Qow--Ep06ua2X40CukYGw-Lfol-21yXZtcu8LFJzfTYLPymkZDDbVMkltck9dMaxncoLVHReiobwz5tNoMmgL7JjXzDXz3PVAoUBc5AduZN1f8Gkw8ckcNBbCJ4BIcSHVtAeEKAv5uP4fuEfA0oF9oRhdyCxYKZJGFh5ogZWH6jjCK0~3zZ45YZnNBIQBS6VzQ__&amp;amp;Key-Pair-Id=APKAJDNICOKANPHVCSBQ" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;in the variable BatchInputPublicAssociationMultiArchive).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Steps to reproduce:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a sample API request via the &lt;A href="https://developers.hubspot.com/docs/api/crm/associations" target="_blank" rel="noopener"&gt;interactive docs&lt;/A&gt; for the endpoint&amp;nbsp;&lt;STRONG&gt;/crm/v4/associations/{fromObjectType}/{toObjectType}/batch/archive&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Copy and paste the Node.js code generated on the right-hand side to a local JS script in a Node.js environment&lt;/LI&gt;&lt;LI&gt;Modify the code wrapping it in an async function and ensuring that theHubspot app token/object reference IDs are correct&lt;/LI&gt;&lt;LI&gt;Ensure the latest version of the &lt;A href="https://www.npmjs.com/package/@hubspot/api-client" target="_blank" rel="noopener"&gt;Hubspot API client Node package&lt;/A&gt; is installed&lt;/LI&gt;&lt;LI&gt;Run script&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For reference, here is my local Node.js code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({
  "accessToken": "OBSCURED_FOR_SECURITY"
});

main();

async function main() {
  const BatchInputPublicAssociationMultiArchive = { inputs: [{"_from":{"id":"80424"},"to":[{"id":"16022770563"}]}] };
  const fromObjectType = "contacts";
  const toObjectType = "companies";

  try {
    const apiResponse = await hubspotClient.crm.associations.batchApi.archive(fromObjectType, toObjectType, BatchInputPublicAssociationMultiArchive);

    console.log(JSON.stringify(apiResponse, null, 2));
  } catch (e) {
    e.message === 'HTTP request failed'
      ? console.error(JSON.stringify(e.response, null, 2))
      : console.error(e)
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 17:38:10 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-CRM-API-V4-documentation-for-batch-association/m-p/810390#M65106</guid>
      <dc:creator>BradySheridan</dc:creator>
      <dc:date>2023-06-21T17:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with CRM API V4 documentation for batch association deletion endpoint</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-CRM-API-V4-documentation-for-batch-association/m-p/810659#M65119</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/421700"&gt;@BradySheridan&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;The Node.js code generated by the interactive docs does indeed contain an invalid reference to the .batch.read method. This method does not exist on the hubspotClient.crm.associations.batchApi object, so the code will not work as expected. The correct line of code should be:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const apiResponse = await hubspotClient.crm.associations.batchApi.archive(fromObjectType, toObjectType, BatchInputPublicAssociationMultiArchive);
&lt;/LI-CODE&gt;
&lt;P&gt;2.&lt;BR /&gt;&lt;BR /&gt;The input data structure generated by the interactive docs is missing the id field for the _from object. This field is required by the API endpoint, so the request will fail if it is not present. The correct input data structure should be:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
  "inputs": [
    {
      "_from": {
        "id": "80424"
      },
      "to": [
        {
          "id": "16022770563"
        }
      ]
    }
  ]
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;update your code with this corrected data structure for the BatchInputPublicAssociationMultiArchive object.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 09:25:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-CRM-API-V4-documentation-for-batch-association/m-p/810659#M65119</guid>
      <dc:creator>himanshurauthan</dc:creator>
      <dc:date>2023-06-22T09:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with CRM API V4 documentation for batch association deletion endpoint</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-CRM-API-V4-documentation-for-batch-association/m-p/810993#M65148</link>
      <description>&lt;P&gt;It looks like the Node.js code in the documentation of endpoint&amp;nbsp;&lt;STRONG&gt;/crm/v4/associations/{fromObjectType}/{toObjectType}/batch/archive&lt;/STRONG&gt; has been updated since this post was created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See the code as of 6/20/2023:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6-20-2023.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/93532iF731082D2A35DDFD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="6-20-2023.png" alt="6-20-2023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;And the code as of 6/22/2023:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6-22-2023.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/93531i4690D2B90D1EE72A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="6-22-2023.png" alt="6-22-2023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const apiResponse = await hubspotClient.crm.associations.v4.batchApi.archive(fromObjectType, toObjectType, BatchInputPublicAssociationMultiArchive);&lt;/LI-CODE&gt;&lt;P&gt;with the automatically generated input structure&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const BatchInputPublicAssociationMultiArchive = {
    "inputs": [
      {
        "_from": {
          "id": "81729"
        },
        "to": [
          {
            "id": "16004868498"
          }
        ]
      }
    ]
  };&lt;/LI-CODE&gt;&lt;P&gt;works as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marking as resolved!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 20:29:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-CRM-API-V4-documentation-for-batch-association/m-p/810993#M65148</guid>
      <dc:creator>BradySheridan</dc:creator>
      <dc:date>2023-06-22T20:29:21Z</dc:date>
    </item>
  </channel>
</rss>

