APIs & Integrations

JHowardAdapt
Member

Public object api merge endpoint undefined in Hubspot client

SOLVE

Hi,

I am trying to access the new merge endpoint found here from the Hubspot client within a custom code block of a Hubspot workflow but I get this error: 

 

"TypeError: Cannot read property 'merge' of undefined"

 

I used the Nodejs example from the docs.

 

It looks like the publicObjectApi isn't accessible in the hubspot client? 

I am wondering if this is maybe because it's a relatively new endpoint? 

 

Any help would be great.

 

1 Accepted solution
JBeatty
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Public object api merge endpoint undefined in Hubspot client

SOLVE

Hi @JHowardAdapt,

 

Inside of a custom code action the included hubspot api client is version 3.4.1. The PublicObjectApi was added in version 6.0.1.

If you want to access this endpoint I would recommend using an http client like axios or request, and just manually calling the api: "/crm/v3/objects/{objectType}/merge". Or if you absolutely must use the HubSpot client you can set up a build system and manually build in the correct version of the client using someting like esbuild. I would not recommend doing this though as it makes your custom code unreadable and quite large to someone without access to the original code.

Best,

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

View solution in original post

3 Replies 3
JBeatty
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Public object api merge endpoint undefined in Hubspot client

SOLVE

Hi @JHowardAdapt,

 

Inside of a custom code action the included hubspot api client is version 3.4.1. The PublicObjectApi was added in version 6.0.1.

If you want to access this endpoint I would recommend using an http client like axios or request, and just manually calling the api: "/crm/v3/objects/{objectType}/merge". Or if you absolutely must use the HubSpot client you can set up a build system and manually build in the correct version of the client using someting like esbuild. I would not recommend doing this though as it makes your custom code unreadable and quite large to someone without access to the original code.

Best,

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

Jaycee_Lewis
Community Manager
Community Manager

Public object api merge endpoint undefined in Hubspot client

SOLVE

Hey, @JHowardAdapt. It looks like @LMeert had some insight on your original post here@JBeatty @Kevin-C, do you have any thoughts on using this in a workflow custom coded action?

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

JHowardAdapt
Member

Public object api merge endpoint undefined in Hubspot client

SOLVE

I tried using the example give from the docs as suggested but it throws an undefined error at the point of publicObjectApi.merge. 

The exact same code works fine outside of custom code blocks, in a standard .js file. 

Whereas within the custom code block it can't seem to find the merge endpoint from the huspotclient import