APIs & Integrations

SHarde
参加者

Unable to post data to Custom objects from Workflow using the API

解決

Hello,

 

I'm trying to post the record to Custom Object from Workflow -- Custom Code Action. I'm using the POST API available here (POST/crm/v3/objects/{objectType}). I'm facing following issue while doing the same:

 

2022-07-21T06:02:34.925Z	ERROR	TypeError: Cannot read property 'create' of undefined
    at Object.exports.main (/var/task/file.js:26:60)
    at Runtime.exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:6:21)
    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)

It seems there is some issue with the API.

 

Here is my code snippet:

const hubspotClient = new hubspot.Client({
accessToken: process.env.ACCESSTOKEN
});

const properties = {
"id": 22,
"userId": 17,
"title": "Hi there",
"completed": true
};
const SimplePublicObjectInput = { properties };
const objectType = "User";

try {
const apiResponse = await hubspotClient.crm.basicApi.create(objectType, SimplePublicObjectInput);
console.log(JSON.stringify(apiResponse.body, null, 2));
} catch (e) {
e.message === 'HTTP request failed'
? console.error(JSON.stringify(e.response, null, 2))
: console.error(e)
}

 

Also, I'm using Oauth token which is already added in Secrets in Custom Code Action.

 

Any leads to resolve this would be helpful.

0 いいね!
1件の承認済みベストアンサー
Teun
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Unable to post data to Custom objects from Workflow using the API

解決

Hi @SHarde ,

 

The docs have to be updated a bit I suppose.

If we look at the contacts endpoint, you can see that the base is a bit different: hubspotClient.crm.contacts.basicApi.create 

So based on that, I suppose the basicApi object is not available directly from the CRM object. Based on the Github repo, I think you should try:

const apiResponse = await hubspotClient.crm.objects.basicApi.create(objectType, SimplePublicObjectInput);



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


元の投稿で解決策を見る

6件の返信
Teun
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Unable to post data to Custom objects from Workflow using the API

解決

Hi @SHarde ,

 

The docs have to be updated a bit I suppose.

If we look at the contacts endpoint, you can see that the base is a bit different: hubspotClient.crm.contacts.basicApi.create 

So based on that, I suppose the basicApi object is not available directly from the CRM object. Based on the Github repo, I think you should try:

const apiResponse = await hubspotClient.crm.objects.basicApi.create(objectType, SimplePublicObjectInput);



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


SHarde
参加者

Unable to post data to Custom objects from Workflow using the API

解決

Hi @Teun , 

 

This solution worked for me. Could you please share a link wherein I can get all the working endpoints? This is a bit of time consuming to wait for an valid API to implement the required usecase. It would be really helpful if the docs get updated asap since lot of time is invested in getting the valid API.

 

Thanks for the help here.

 

Regards,

Swapnil

0 いいね!
Teun
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Unable to post data to Custom objects from Workflow using the API

解決

Hi @SHarde ,


Awesome! Happy it worked. 
You can use the GitHub repo as an indication of how to build the endpoint. The discovery folder is the 'base'. And if you navigate to the crm folder that would you mean you are looking at hubspotClient.crm, if you navigate to the contacts folder, you are looking at hubspotClient.crm.contacts 

 

But I agree, the docs need an update 🙂



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Teun
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Unable to post data to Custom objects from Workflow using the API

解決

I'm just going to mention @Jaycee_Lewis here to get the docs updated if I am correct 😁 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Jaycee_Lewis
コミュニティーマネージャー
コミュニティーマネージャー

Unable to post data to Custom objects from Workflow using the API

解決

Hey, @Teun 🙌 I am going to work with the docs team and submit a request. I may have more questions (I'm always learning) I'll tag you here if I do! 

 

Talk soon — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




0 いいね!
SHarde
参加者

Unable to post data to Custom objects from Workflow using the API

解決

@Teun -- Coud you please help here. We had resolved similar kind of issue couple of days back Any leads would be helpful. Thank you!!

0 いいね!