Getting Started with APIs

Really basic question.

I am looking to get started with API cqalls so that I can set line item values in bespoke code in workflows.

I have set up a private app and I have an access token. I then add the following to my bespoke code -

--

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

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

const hubspotClient = new hubspot.Client({accessToken: pat-na1-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX});

--

The XXX represent hexadecimal numbers.
This ccreeates a parse error in the bespoke code - 5:72 Parsing error: Invalid number

Hey, @CClokeBrowne :waving_hand: Did you get this resolved?

If not, it looks like a formatting issue. You’re missing single or double quotes around your token. When using a string in JavaScript, you need to ensure that it is enclosed in quotes. So, something like this:

const hubspot = require('@hubspot/api-client');
exports.main = async (event, callback) => {
 const hubspotClient = new hubspot.Client({ accessToken: 'pat-na1-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' });
 // Your awesome code here...
}

Have fun building! — Jaycee

Thany you - Your solution makes sense. I did regt it resolced by adding a SECRET and putting my key in there.