Custom Object API error

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”

}

]

}’

Hi @kaoki Can you post your api request log ?

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”
}

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’,

url: ‘https://api.hubapi.com/crm/v3/schemas’,

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(options, function (error, response, body) {

if (error) throw 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.

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-1624948680.1599571013

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 !

You beat me to the punch!

@spotthehub

This works for me.

Thank you.