hubspot api-client in custom code: crm associations BatchApi read does not retrieve all associations
Hi
I try to get all associated companies to one contact in a custom code secition of a workflow. But the result is only one company (primary?).
Is the api or my code wrong?
I use
My code looks like:
const hubspot = require('@hubspot/api-client');
exports.main = async (event, callback) => {
/*****
Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.
*****/
const hubspotClient = new hubspot.Client({
accessToken: process.env.token
});
try {
const hs_object_id = event.inputFields['hs_object_id'];
const batchInputPublicObjectId = {
inputs: [{
id: hs_object_id
}]
};
const apiResponse = await hubspotClient.crm.associations.batchApi.read('0-1', '0-2', batchInputPublicObjectId);
console.log(JSON.stringify(apiResponse, null, 2));
} catch (error) {
console.error(error);
// We will automatically retry when the code fails because of a rate limiting error from the HubSpot API.
throw error;
}
/*****
Use the callback function to output data that can be used in later actions in your workflow.
*****/
callback({
outputFields: {}
});
}