Associations API returning empty contact objects

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?

Hey, @jsoldi :waving_hand: Thanks for the question. Did you get this resolved? If not, do you get a same/similar result when making a raw request using Postman?

Thanks! — Jaycee

OK now I know what the issue was.

I tested using postman and did get some data. The hubspot client I was using was version 8.1.0. I’m not sure which version of the API this package uses behind the scenes but the whole mess was because of this. I’ll make sure I use the right versions.