I’m using the hubspot/api-client v8.1.0 package for NodeJS. Here is a piece of code I’m using to test getting contacts associated to deals:
const deals = await Api.dealsByStage('Grundbuchdaten Hinzugefügt', 1000, 100, _ => true);
const contacts: Record<string, any> = {};
for (let deal of deals) {
console.log(`Processing deal ${deal.id}`);
const dealContacts = await Api.client.crm.deals.associationsApi.getAll(deal.id, 'contact');
contacts[deal.id] = dealContacts.results;
}
await fs.writeFile('./sample.json', JSON.stringify(contacts, null, 2));
The Api.dealsByStage function is a function I wrote that gets a list of deals. That works fine because I can see the `for` loop looping through each deal ID. But then the call to associationsApi.getAll is the one acting weird. I do get a list of either 0, 1 or 2 empty objects (with no properties, not even the contact ID). If I was getting an empty list of contacts I guess it could be that the deals have no associated contacts, but then I’m actually getting something back. Here is an example of the results I get:
"5336323558": [],
"5336234188": [
{}
],
"5336291063": [
{},
{}
],
"5336870390": [],
Am I doing something wrong or maybe using the wrong API?