I’m running into an issue with the HubSpot API when trying to retrieve association labels for (deal to deal) associations.
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.
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.
Has anyone else run into this issue or found a workaround? Anything specific with scopes here? Appreciate any insights,
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.
Did this and was able to get the label and typeId. Let me know if this works for you.
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 > 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 && association.associationTypes.length > 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);
}
Edit: Upon looking further the issue is the way you were looking at the response body. The otherDealId = association.id should be otherDealId = association.toObjectId
Also, not including getPage, didn't return the full response but only what you were seeing before.
@v3rnalequinox which endpoint are you using and can you send a screenshot of the error you are seeing?
You should be able to see them by using the basic list endpoint ObjectType - Deal ObjectId - recordId of the deal that is associated to multiple deals toObjectType - Deal
Hello @BBaber 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.
the call is
for (const association of allAssociations) { const otherDealId = association.id; console.log("Checking associated deal ID:", otherDealId); console.log("Raw association object:", JSON.stringify(association));
But I'm getting back
INFO***** Fetching deals associated with deal ID ***** xxxx00
INFOAssociated deals API response received
INFONumber of associated deals found: 1
INFOFound associated deals, checking for any association labels...
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.
console.log("Number of associated deals found:", allAssociations.length);
if (allAssociations.length > 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.id;
clearly trying to grab the info via console logs since it isn't connecting it for me.
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.
Did this and was able to get the label and typeId. Let me know if this works for you.
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 > 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 && association.associationTypes.length > 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);
}
Edit: Upon looking further the issue is the way you were looking at the response body. The otherDealId = association.id should be otherDealId = association.toObjectId
Also, not including getPage, didn't return the full response but only what you were seeing before.