Hey, I am encountering an isssue with API v3 for Batch Creating a Custom Objects.
Custom object required property: prop_one - field type: Dropdown select
All works while I try to do it from API tool - site endpoints and Postman.
Issue here is that I need to provide code for Node.js Meteor based App, therefore I went for AzureFunctions. No issue with AZF integration etc. so far until now: Code form HS APIv3 endpoints:
While doing so: *** Error throw: "Cannot create object with type: {fullyQualifiedName}. The following required properties were missing: [prop_one]" "HTTP request failed"
Unless i am too late to this party, the call on the documentation is incorrect. Which it is for mosty of these calls as they have left out a vital part of the line.
So you have
await hubspotClient.crm.batchApi.create
which will bring up the error of cannot read property of create on undefined.
All these calls need an extra part to them
await hubspotClient.crm.objects.batchApi.create
so here i have added objects, this will make the call work.
You can find these out by digging into the code of the node api provided to see where the calls actually go and what needs to be in them
May 5, 20226:27 AM - edited May 20, 202212:24 PM
Contributor | Platinum Partner
Create Batch API v3 Custom Object
Hey @jpsanchez Thanks for your reply, thanks for your time.
I believe issue is more complex, this was quite dificult to explain maybe, not to post any sensitive data. Lets recap. I use this to Create Batch of Custom Objects: POST /crm/v3/objects/{objectType}/batch/create
Custom object required property in HS instance declared as follow: prop_one (internal value)
field type: Dropdown select
1 - this might be the issue, because of de-duplication, I thought that first, but Batch Creation takes, as I understand, this under consideration because it is about creating instance custom object in batches like so:
while there is difference with at lease one prop value this will be fine, two instances of the custom object will be created.
2.
const objectType = "2-104078180" - this is my custom objectType id Please find:
Retrieve existing custom objects To retrieve all custom objects, make a GET request to /crm/v3/schemas.
To retrieve a specific custom object, make a GET request to one of the following endpoints:
/crm/v3/schemas/{objectTypeId} /crm/v3/schemas/{fullyQualifiedName}. You can find an object's fullyQualifiedName in its schema, which is derived from p{portal_id}_{object_name}.
For example, your request URL may look like the following:
Issue here is different nature: I am not able to define body.param for body input other than hardcoded values using Batch Create API v3 for custom object:
node.js code - does not work in node.js application.
my function App: the same code from endpoint throw an error: *** Error throw: "Cannot read property 'create' of undefined"
I have worked this around using:
modified code ( while try catch block is handled in AZFunction )
and Not wrapped endpoint(s) recipies of '@hubspot/api-client' package:
async function searchForShiftsbyMonth(context, query, body) {
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({"apiKey":"xxx"});
let inputBody = { "inputs": [{"properties":{"prop_one":"prop name","prop_two":"5:30"}},
{"properties":
{"prop_one":"prop name","prop_two":"6:30"}}] }
const objectType = "2-104078180";
//also have tried with fullyQualifiedName
//which is derived from p{portal_id}_{object_name}
const result = await hubspotClient.apiRequest({
method: 'POST',
path: `/crm/v3/objects/${objectType}/batch/create?`,
body: inputBody,
});
return result.body;
}
So as you can see I have an Azure Functions that will hit endpoint, and return RES
and this one works.
Issue here - why code rfom copied from HS Guide does work on HS page but in Node.js app throws error? *** Error throw: "Cannot read property 'create' of undefined" But like I said this was overcome.
What I am not able to figure out is how to code params to be passed as body.params in HTTP POST request: instead of hardcodding this in the App: like so let inputBody = { "inputs": [
{"properties":{"prop_one":"prop name but different one","prop_two":"8:30"}}, {"properties":{"prop_one":"prop name","prop_two":"9:30"}}
] }
but so far I am getting this code errot throws: *** Error throw: "Cannot create object with type: {fullyQualifiedName of my custom property here} . The following required properties were missing: [prop_one]" "HTTP request failed"