APIs & Integrations

kaoki
Contributor | Platinum Partner
Contributor | Platinum Partner

Custom Object API error

SOLVE

Hello community.

 

I`m trying to create a custom object with API(POST/crm-object-schemas/v3/schemas

I get error when I specify property type "number" or "date".(only "string" works fine.)

Please advise.

 

Thank you and best regards.

 

error message

{
"status": "error",
"message": "Unexpected property type 'date', expected one of: [string, object_coordinates, json]",
"correlationId": "5caa8194-4a96-4f6f-b832-2e373b25ba7f",
"category": "VALIDATION_ERROR"
}
 
request (curl)
curl --location --request POST 'https://api.hubapi.com/crm-object-schemas/v3/schemas?hapikey={ API_KEY }' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "shipment",
"labels": {
"singular": "出荷",
"plural": "出荷"
},
"primaryDisplayProperty": "name",
"secondaryDisplayProperty": [
"code",
"unit_price"
],
"requiredProperties": [
"name",
"code",
"unit_price"
],
"searchableProperties": [
"name",
"code",
"unit_price"
],
"properties": [
{
"name": "no",
"label": "出荷伝票No",
"hasUniqueValue": true,
"type": "string",
"displayOrder": 1
},
{
"name": "status",
"label": "ステータス",
"type": "string"
},
{
"name": "date",
"label": "出荷予定日",
"type": "date"
}
]
}'
1 Accepted solution
spotthehub
Solution
Participant

Custom Object API error

SOLVE

I figured out the issue.  The documentation on this page: https://developers.hubspot.com/docs/api/crm/crm-custom-objects?_ga=2.165441468.2023144461.1605542585...

 

is missing the field property of  [fieldType:'date] when you generate the example code.

 

This would be the whole request:

 

{name: 'date_property_name'label: 'Date Property Label'type: 'date'fieldType:'date'}

View solution in original post

6 Replies 6
kaoki
Contributor | Platinum Partner
Contributor | Platinum Partner

Custom Object API error

SOLVE

@spotthehub 

This works for me.

Thank you.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Custom Object API error

SOLVE

@spotthehub !

You beat me to the punch! 


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!

0 Upvotes
spotthehub
Solution
Participant

Custom Object API error

SOLVE

I figured out the issue.  The documentation on this page: https://developers.hubspot.com/docs/api/crm/crm-custom-objects?_ga=2.165441468.2023144461.1605542585...

 

is missing the field property of  [fieldType:'date] when you generate the example code.

 

This would be the whole request:

 

{name: 'date_property_name'label: 'Date Property Label'type: 'date'fieldType:'date'}
spotthehub
Participant

Custom Object API error

SOLVE

I also seem to not be able to create a custom object and set a required date/datetime field:

 

Here is the request:

var request = require("request");

var options = {
  method: 'POST',
  qs: {hapikey: 'YOUR_API_KEY'},
  headers: {accept: 'application/json''content-type': 'application/json'},
  body: {
    labels: {singular: 'Virtual Event'plural: 'Virtual Events'},
    requiredProperties: ['virtual_event_title''virtual_event_date'],
    name: 'virtual_event',
    primaryDisplayProperty: 'virtual_event_title',
    properties: [
      {
        name: 'virtual_event_title',
        label: 'Virtual Event Title',
        isPrimaryDisplayLabel: true,
        type: 'string'
      },
      {name: 'virtual_event_date'label: 'Virtual Event Date'type: 'date'}
    ],
    associatedObjects: ['CONTACT''COMPANY'],
    metaType: 'PORTAL_SPECIFIC',
    secondaryDisplayProperties: ['virtual_event_date','date']
  },
  json: true
};

request(optionsfunction (errorresponsebody) {
  if (errorthrow new Error(error);

  console.log(body);
});
 
Response:

 

{
status: 'error',
message: "Unexpected property type 'date', expected one of: [string, object_coordinates, json]",
correlationId: '300fe4d9-3043-4c06-bacb-e6c46e55fc80',
category: 'VALIDATION_ERROR'
}

 

Not sure if I'm doing something wrong or if there is a bug in the API or documentation. 

0 Upvotes
quentin_lamamy
Key Advisor | Diamond Partner
Key Advisor | Diamond Partner

Custom Object API error

SOLVE

Hi @kaoki Can you post your api request log ?

hsSign_smaller.png


Seramlo
Participant

Custom Object API error

SOLVE

Same error here with property type "date" and "datetime", using postman and testing from API docs:

 

HTTP 400

{
"status": "error",
"message": "Unexpected property type 'date', expected one of: [string, object_coordinates, json]",
"correlationId": "21ef7877-b0cb-492b-a755-32ed9625b411",
"category": "VALIDATION_ERROR"
}