# Associations API returning empty contact objects

**URL:** <https://community.hubspot.com/t/associations-api-returning-empty-contact-objects/87870>\
**Category:** APIs & Integrations\
**Tags:** object, contacts\
**Created:** [August 19, 2023, 10:25pm UTC](https://community.hubspot.com/t/associations-api-returning-empty-contact-objects/87870 "2023-08-19T22:25:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsoldi](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jsoldi](https://community.hubspot.com/u/jsoldi)\
**Post date:** [August 19, 2023, 10:25pm UTC](https://community.hubspot.com/t/associations-api-returning-empty-contact-objects/87870/1 "2023-08-19T22:25:48Z")

</div>

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:

```lia-code-sample
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:

```lia-code-sample
"5336323558": [],
"5336234188": [
 {}
],
"5336291063": [
 {},
 {}
],
"5336870390": [],

```

Am I doing something wrong or maybe using the wrong API?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 22, 2023, 10:12pm UTC](https://community.hubspot.com/t/associations-api-returning-empty-contact-objects/87870/2 "2023-08-22T22:12:38Z")

</div>

Hey, @jsoldi 👋 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

---

<div class="post-metadata">

**Author:** ![jsoldi](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jsoldi](https://community.hubspot.com/u/jsoldi)\
**Post date:** [August 24, 2023, 5:41pm UTC](https://community.hubspot.com/t/associations-api-returning-empty-contact-objects/87870/3 "2023-08-24T17:41:21Z")

</div>

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.
