# Api for contact Associations V4

**URL:** <https://community.hubspot.com/t/api-for-contact-associations-v4/96686>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [December 22, 2023, 3:09pm UTC](https://community.hubspot.com/t/api-for-contact-associations-v4/96686 "2023-12-22T15:09:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GBreccia](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GBreccia](https://community.hubspot.com/u/GBreccia)\
**Post date:** [December 22, 2023, 3:09pm UTC](https://community.hubspot.com/t/api-for-contact-associations-v4/96686/1 "2023-12-22T15:09:56Z")

</div>

HI,  
i run this custom function in a workflow:

const hubspot = require(‘@hubspot/api-client’);

exports.main = async (event, callback) =\> {  
const hubspotClient = new hubspot.Client({“accessToken”:“xxxxxxxxx”});  
const objectType = “contact”;  
const objectId = event.inputFields[‘rec’]; // record id of contact enrolled  
const toObjectType = “company”;  
const limit = 500;

try {  
const apiResponse = await hubspotClient.crm.associations.v4.basicApi.getPage(objectType, objectId, toObjectType, undefined, limit);  
console.log(JSON.stringify(apiResponse.body, null, 2));

callback({  
outputFields: {  
response : JSON.stringify(apiResponse.body, null, 2),  
contactID : objectId  
}  
});  
} catch (error) {  
console.error("Errore nell’API call: ", error);  
// Gestisci l’errore come necessario  
}  
}

But apiresponse is empty.  
Where I’m wrong?
