How to create a Custom Object Record using Javascript

Hi,

I’m trying to create a custom code workflow to create a new record on a custom object. This is what I’ve currently got but I’m getting an error saying Unhandled Promise Rejection.

Code:

hubspotClient.crm.customobject.basicApi.create(item.id, {
‘properties’: {
‘property’: property value
}

I’d like to know what the format is to access the custom object to create in this way as I’ve tried different iterations of custom_object etc but no luck. Any help with this would be much appreciated.

Hi @DEstillero

The API documentation has some code examples. You’ll want to look at Create in the Objects tab.

It also depends on how you’re making the API call - are you using Node.js in a custom code action, or are you making a call from an external (or local) app using vanilla JavaScript? The documentation has Node.js but for vanilla you’ll want to use a fetch function using the endpoint in the documentation.

- Zach

Hi @zachh,

I’m using Node.js in a custom code action, I’ve tried to do the below, in which 19018666 is the custom object ID on hubspot but that doesn’t work either.

hubspotClient.crm.19018666.basicApi.create(item.id, …

What would I use to replace customobject in:

hubspotClient.crm.customobject.basicApi.create(item.id, {
‘properties’: {
‘property’: property value
}