<?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 Retrieving Association Labels for (deal to deal) Associations via HubSpot API in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122297#M80935</link>
    <description>&lt;P&gt;I was getting the same log when I tested on my end. I believe its because the batchApi endpoint only gives generic info and not detailed information.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Did this and was able to get the label and typeId. Let me know if this works for you.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;try {
  console.log("***** Fetching deals associated with deal ID *****", dealId);
  const associationsResult = await hubspotClient.crm.associations.v4.basicApi.getPage(
    "DEAL",
    dealId,
    "DEAL",
    undefined,
    500
  );
  console.log("Associated deals API response received");

  const allAssociations = associationsResult.results;
  console.log("Number of associated deals found:", allAssociations.length);

  if (allAssociations.length &amp;gt; 0) {
    console.log("Found associated deals, checking for any association labels...");
    console.log("Raw associations data:", JSON.stringify(allAssociations));
    for (const association of allAssociations) {
      const otherDealId = association.toObjectId;
      console.log("Checking associated deal ID:", otherDealId);
      if (association.associationTypes &amp;amp;&amp;amp; association.associationTypes.length &amp;gt; 0) {
        for (const assocType of association.associationTypes) {
          console.log("Association details for deal " + otherDealId + ": Label: " + assocType.label + ", Type ID: " + assocType.typeId);
        }
      } else {
        console.log("No detailed association types available for deal " + otherDealId + ".");
      }
    }
  }
} catch (error) {
  console.error("Error fetching associations:", error);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Edit:&lt;BR /&gt;Upon looking further the issue is the way you were looking at the response body.&amp;nbsp;&lt;BR /&gt;The otherDealId = association.id should be otherDealId = association.toObjectId&lt;BR /&gt;&lt;BR /&gt;Also, not including getPage, didn't return the full response but only what you were seeing before.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ accessToken: process.env.TOKEN });

exports.main = async (event, callback) =&amp;gt; {
  try {
    const dealId = event.object.objectId;
    console.log("***** Fetching deals associated with deal ID *****", dealId);
    
    const BatchInputPublicFetchAssociationsBatchRequest = { inputs: [{ id: dealId }] };
    const fromObjectType = "Deal";
    const toObjectType = "Deal";
    
    const associationsResult = await hubspotClient.crm.associations.v4.batchApi.getPage(
      fromObjectType,
      toObjectType,
      BatchInputPublicFetchAssociationsBatchRequest
    );
    console.log("Associated deals API response received");
    
    const allAssociations = associationsResult.results.flatMap(
      (result) =&amp;gt; result.to || []
    );
    console.log("Number of associated deals found:", allAssociations.length);
    
    if (allAssociations.length &amp;gt; 0) {
      console.log("Found associated deals, checking for any association labels...");
      console.log("Raw associations data:", JSON.stringify(allAssociations, null, 2));
      for (const association of allAssociations) {
        const otherDealId = association.toObjectId;
        console.log("Checking associated deal ID:", otherDealId);
        // continue processing using otherDealId...
      }
    }
    callback({ outputFields: { success: true } });
  } catch (error) {
    console.error("Error fetching associations:", error);
    callback({ outputFields: { errorMessage: error.message, success: false } });
  }
};&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Mar 2025 01:10:08 GMT</pubDate>
    <dc:creator>BBaber</dc:creator>
    <dc:date>2025-03-14T01:10:08Z</dc:date>
    <item>
      <title>Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122189#M80930</link>
      <description>&lt;P class=""&gt;Hey everyone,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;I’m running into an issue with the HubSpot API when trying to retrieve association labels for (deal to deal) associations.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;For context, I have a Deal that is associated with two other Deals using a custom Association Label called Renewal (Deal to Deal + 1 to Many + USER_DEFINED). When I query the HubSpot API, I’m not getting the Association Label Name or ID in the response. The results are always empty regardless of following V3 or V4 documentation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;I’m using a private app and believe I have the correct scopes as I am not seeing any scope related issues in the response like I have histrocially. I am able to access just about every other part of the API with no issues.&lt;BR /&gt;&lt;BR /&gt;Has anyone else run into this issue or found a workaround?&amp;nbsp;Anything specific with scopes here? Appreciate any insights,&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 19:27:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122189#M80930</guid>
      <dc:creator>v3rnalequinox</dc:creator>
      <dc:date>2025-03-13T19:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122217#M80931</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/914500"&gt;@v3rnalequinox&lt;/a&gt;&amp;nbsp; which endpoint are you using and can you send a screenshot of the error you are seeing?&lt;BR /&gt;&lt;BR /&gt;You should be able to see them by using the &lt;STRONG&gt;&lt;A href="https://developers.hubspot.com/docs/reference/api/crm/associations/association-details#get-%2Fcrm%2Fv4%2Fobjects%2F%7Bobjecttype%7D%2F%7Bobjectid%7D%2Fassociations%2F%7Btoobjecttype%7D" target="_blank" rel="noopener"&gt;basic list endpoint&lt;/A&gt;&lt;BR /&gt;&lt;/STRONG&gt;ObjectType - &lt;STRONG&gt;Deal&lt;/STRONG&gt;&lt;BR /&gt;ObjectId - &lt;STRONG&gt;recordId&lt;/STRONG&gt; of the deal that is associated to multiple deals&lt;BR /&gt;toObjectType - &lt;STRONG&gt;Deal&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;cURL request should look like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl --request GET \
--url 'https://api.hubapi.com/crm/v4/objects/Deal/34355736403/associations/Deal?limit=500' \
--header 'authorization: Bearer YOUR_ACCESS_TOKEN'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;I would love to hear your use case! I've spent the last month detangling the Associations API&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 20:37:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122217#M80931</guid>
      <dc:creator>BBaber</dc:creator>
      <dc:date>2025-03-13T20:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122265#M80932</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/429247"&gt;@BBaber&lt;/a&gt;&amp;nbsp; I'm running into something similar! I'm trying to find a specific association label for deal to deal, and using the API to see if that label is present. What I'm getting back is the type deal to deal, but not the label I'm looking for. Honestly, I'd be satisified with the internal Association ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the call is&lt;/P&gt;&lt;P&gt;for (const association of allAssociations) {&lt;BR /&gt;const otherDealId = association.id;&lt;BR /&gt;console.log("Checking associated deal ID:", otherDealId);&lt;BR /&gt;console.log("Raw association object:", JSON.stringify(association));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm getting back&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;INFO&lt;/SPAN&gt; &lt;SPAN&gt;***** Fetching deals associated with deal ID ***** xxxx00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;INFO&lt;/SPAN&gt; &lt;SPAN&gt;Associated deals API response received&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;INFO&lt;/SPAN&gt; &lt;SPAN&gt;Number of associated deals found: 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;INFO&lt;/SPAN&gt; &lt;SPAN&gt;Found associated deals, checking for any association labels...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;INFO&lt;/SPAN&gt; &lt;SPAN&gt;Raw associations data: [{"id":"xxx8849","type":"deal_to_deal"}]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to call the association.id but no dice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 22:07:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122265#M80932</guid>
      <dc:creator>CChunn24</dc:creator>
      <dc:date>2025-03-13T22:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122285#M80933</link>
      <description>can you share a snippet of the call you are making that finds the associations? This part only shows me how you are parsing the information captured in the call.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Mar 2025 22:53:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122285#M80933</guid>
      <dc:creator>BBaber</dc:creator>
      <dc:date>2025-03-13T22:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122286#M80934</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;BR /&gt;This is the part for the association label.&amp;nbsp;&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;console.log("***** Fetching deals associated with deal ID *****", dealId);&lt;BR /&gt;const associationsResult =&lt;BR /&gt;await hubspotClient.crm.associations.batchApi.read("deals", "deals", {&lt;BR /&gt;inputs: [{ id: dealId }],&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;console.log("Associated deals API response received");&lt;/P&gt;&lt;P&gt;const allAssociations = associationsResult.results.flatMap(&lt;BR /&gt;(association) =&amp;gt; association.to || []&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;console.log("Number of associated deals found:", allAssociations.length);&lt;/P&gt;&lt;P&gt;if (allAssociations.length &amp;gt; 0) {&lt;BR /&gt;console.log(&lt;BR /&gt;"Found associated deals, checking for any association labels..."&lt;BR /&gt;);&lt;BR /&gt;console.log("Raw associations data:", JSON.stringify(allAssociations));&lt;/P&gt;&lt;P&gt;for (const association of allAssociations) {&lt;BR /&gt;const otherDealId = association.id;&lt;BR /&gt;&lt;BR /&gt;clearly trying to grab the info via console logs since it isn't connecting it for me.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 23:01:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122286#M80934</guid>
      <dc:creator>CChunn24</dc:creator>
      <dc:date>2025-03-13T23:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122297#M80935</link>
      <description>&lt;P&gt;I was getting the same log when I tested on my end. I believe its because the batchApi endpoint only gives generic info and not detailed information.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Did this and was able to get the label and typeId. Let me know if this works for you.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;try {
  console.log("***** Fetching deals associated with deal ID *****", dealId);
  const associationsResult = await hubspotClient.crm.associations.v4.basicApi.getPage(
    "DEAL",
    dealId,
    "DEAL",
    undefined,
    500
  );
  console.log("Associated deals API response received");

  const allAssociations = associationsResult.results;
  console.log("Number of associated deals found:", allAssociations.length);

  if (allAssociations.length &amp;gt; 0) {
    console.log("Found associated deals, checking for any association labels...");
    console.log("Raw associations data:", JSON.stringify(allAssociations));
    for (const association of allAssociations) {
      const otherDealId = association.toObjectId;
      console.log("Checking associated deal ID:", otherDealId);
      if (association.associationTypes &amp;amp;&amp;amp; association.associationTypes.length &amp;gt; 0) {
        for (const assocType of association.associationTypes) {
          console.log("Association details for deal " + otherDealId + ": Label: " + assocType.label + ", Type ID: " + assocType.typeId);
        }
      } else {
        console.log("No detailed association types available for deal " + otherDealId + ".");
      }
    }
  }
} catch (error) {
  console.error("Error fetching associations:", error);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Edit:&lt;BR /&gt;Upon looking further the issue is the way you were looking at the response body.&amp;nbsp;&lt;BR /&gt;The otherDealId = association.id should be otherDealId = association.toObjectId&lt;BR /&gt;&lt;BR /&gt;Also, not including getPage, didn't return the full response but only what you were seeing before.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ accessToken: process.env.TOKEN });

exports.main = async (event, callback) =&amp;gt; {
  try {
    const dealId = event.object.objectId;
    console.log("***** Fetching deals associated with deal ID *****", dealId);
    
    const BatchInputPublicFetchAssociationsBatchRequest = { inputs: [{ id: dealId }] };
    const fromObjectType = "Deal";
    const toObjectType = "Deal";
    
    const associationsResult = await hubspotClient.crm.associations.v4.batchApi.getPage(
      fromObjectType,
      toObjectType,
      BatchInputPublicFetchAssociationsBatchRequest
    );
    console.log("Associated deals API response received");
    
    const allAssociations = associationsResult.results.flatMap(
      (result) =&amp;gt; result.to || []
    );
    console.log("Number of associated deals found:", allAssociations.length);
    
    if (allAssociations.length &amp;gt; 0) {
      console.log("Found associated deals, checking for any association labels...");
      console.log("Raw associations data:", JSON.stringify(allAssociations, null, 2));
      for (const association of allAssociations) {
        const otherDealId = association.toObjectId;
        console.log("Checking associated deal ID:", otherDealId);
        // continue processing using otherDealId...
      }
    }
    callback({ outputFields: { success: true } });
  } catch (error) {
    console.error("Error fetching associations:", error);
    callback({ outputFields: { errorMessage: error.message, success: false } });
  }
};&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 01:10:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122297#M80935</guid>
      <dc:creator>BBaber</dc:creator>
      <dc:date>2025-03-14T01:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122471#M80936</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/429247"&gt;@BBaber&lt;/a&gt;&amp;nbsp; What a huge help. I still need to fold into the call, but this absolutely provided the labels I was looking for! Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 12:45:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122471#M80936</guid>
      <dc:creator>CChunn24</dc:creator>
      <dc:date>2025-03-14T12:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issues Retrieving Association Labels for (deal to deal) Associations via HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122488#M80937</link>
      <description>&lt;P&gt;Cannot thank you enough&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/429247"&gt;@BBaber&lt;/a&gt;&amp;nbsp;- Your solution nailed it, and we are off! You rock&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 13:36:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-Retrieving-Association-Labels-for-deal-to-deal/m-p/1122488#M80937</guid>
      <dc:creator>v3rnalequinox</dc:creator>
      <dc:date>2025-03-14T13:36:28Z</dc:date>
    </item>
  </channel>
</rss>

