Can't update contact property

Hey team,

I have a date picker property called test_2 which was created manually from the HubSpot UI.

I’m trying to update this property to be of type dateTime so I can use it for a full date+time value and not just date.

Using the HubSpot API I’ve tried running this:

Spoiler

curl -v -X PUT https://api.hubapi.com/properties/v1/contacts/properties/named/test_2 \
-H ‘authorization: Bearer MY-API-KEY’ \
-H ‘Content-Type: application/json’ \
-d ‘{“name”: “test_2”, “groupName”: “contactactivity”, “type”: “dateTime”, “fieldType”: “date”}’

And I get this error:

Spoiler

{“status”:“error”,“message”:“Invalid input JSON on line 1, column 60: Cannot deserialize value of type `com.google.protobuf.Descriptors$EnumDescriptor` from String \“dateTime\”: value not one of declared Enum instance names”,“correlationId”:“f237ffad-f2b1-4eea-a87e-5f7055b66208”}%

Can you please assist?

Thank you!

@Shahar_Azulay have you verified that your data for the datetime value has the correct formatting?

Time values are represented in ISO 8601 format in responses, but the APIs will accept either of two formats for date and time values:

  • ISO 8601 formatted strings: depending on the type of data, these will be one of two different formats:
    • For values that represent a specific date, the complete date format will be used: YYYY-MM-DD (e.g. 2020-02-29)
    • For values that represent a specific date and time, the complete date plus hours, minutes, seconds, and a decimal fraction of a second format will be used: YYYY-MM-DDThh:mm:ss.sTZD (e.g. 2020-02-29T03:30:17.000Z). All times are represented in UTC, so the values will always use the UTC designator “Z.”
  • UNIX-formatted timestamps in milliseconds: timestamp values in milliseconds, which are represented in UTC time. For example, the timestamp value 1427997766000 translates to 02 Apr 2015 18:02:46 UTC, or April 2nd, 2015, 2:02:46 PM EDT (Eastern Daylight Saving Time).

Hey @Jnix284 - I’m not updating value, just the type of the field.

I have a field in Hubspot with valid dates (it’s a date picker).

@Shahar_Azulay sorry for the delayed response, I was out for the holidays.

Thanks for clarifying, I thought maybe you were populating the date from an external source.

The HubSpot Date Picker field type only stores the Date value, there is no Time value associated.

Here is how a date value is stored with a Date Picker property:

From the HubSpot Knowledge Base Property field types:

There are HubSpot date fields that store time, they are timestamps for Activities and show like this:

The only way to store date and time would be if you are populating the data via API.

From the developer API documentation:

Hope this helps clarify!

Hey Jennifer - hoping you can help. I’m having a fairly similar problem. When trying to create the datetime property, here’s the error I get. Can you help??

HTTP 400

{
“status”: “error”,
“message”: “Property failed validation.”,
“correlationId”: “cd9d4de0-6715-46b2-97e0-70ac559142e3”,
“category”: “VALIDATION_ERROR”,
“subCategory”: “Properties.PROPERTY_CREATE_FAILED_VALIDATION”
}

Hi @CMyhra I’m sorry, I don’t have enough detail to know what would cause the validation error. I recommend creating a new post in this discussion so it’s easier for others to find and help.

@Jnix284 I posted the question with more info HERE