ownersApi.getPage cannot read

Hi,

I want to get userId in custom code action in Hubspot worflow.

I use hubspot API, code below:

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

exports.main = async (event, callback) => {

const hubspotClient = new hubspot.Client({
apiKey: process.env.HAPIKEY
});

const email = event.inputFields[‘email’];
const after = 0;
const limit = 1;
const archived = false;

try {
const apiResponse = await hubspotClient.crm.owners.ownersApi.getPage(email, after, limit, archived);
console.log(JSON.stringify(apiResponse.body, null, 2));
} catch (err) {
console.error(err);
//throw err;
}

callback({
//outputFields: {
// email: email
// }
});
}

Unfortunately when I test it I get this error:

2021-11-09T16:06:10.802Z	ERROR	TypeError: Cannot read property 'getPage' of undefined
 at Object.exports.main (/var/task/file.js:17:67)
 at Runtime.exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:6:21)
 at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)

Looks as if getPage method was not avilable.

I would be gratefull if someone could help me solve this problem.

Hi @PKrupa,

I’m unfortunately not knowledgeable enough in this subject, but I wanted to tag a couple of our amazing API experts to see if they can help out:

hi @piersg, @Bryantworks, @lynton, @dannio do you have any suggestions for @PKrupa? Thank you!

Cheers
Mia, Community Team

I’m also experiencing this exact issue.

Hi i got wat was cusing the problem.

Hubspot/api-client library verison ^3.4.1 (that custom code in Node.js supports) does not include ownersAPI. It was added in newer release.

I wish Hubspot team would update it soon.

Artenatively Hubspot added option to write custom code in Phyton which supports newer version 4.0.4.

Hi @PKrupa, thank you so much for sharing this information, I’ll forward it to our team!

Cheers
Mia, Community Team

Actually, @PKrupa could you add this to the list of of the repo issues here? You discovered it so the credit should go to you. :slightly_smiling_face:

Thank you!