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?