APIs & Integrations

Not applicable

How to update contact datepicker field value via Contact API?

Hello!

I’m trying to update contact’s custom field (datepicker type) value via API [0] , and API returns error message “Property values were not valid” . Tried sending different values (“2016-10-05”, “2016-10-05 11:11:11”, timestamp), no success. Do you have any recommendations or sources what to read to solve this issue? I could not find anything related to value requirements.

[0] http://developers.hubspot.com/docs/methods/contacts/update_contact

0 Upvotes
7 Replies 7
Not applicable

How to update contact datepicker field value via Contact API?

I tried these timestamps:
1480032000000 (2016-11-25 00:00:00) - accepted
1480035600000 (2016-11-25 01:00:00) - bad request

strange…

0 Upvotes
HenrikJanningJu
Member

How to update contact datepicker field value via Contact API?

Thanx a lot - you just saved my day :slight_smile:

/Henrik

0 Upvotes
HenrikJanningJu
Member

How to update contact datepicker field value via Contact API?

I can’t get update of datepicker field value to work the following way:

URL:
https://api.hubapi.com/contacts/v1/contact/vid/56770/profile?hapikey=MyKey

PostData:
{
“properties”: [
{
“property”: “trial_user_create_date”,
“value”: “1411084800”
}
]
}

0 Upvotes
robertainslie
HubSpot Employee
HubSpot Employee

How to update contact datepicker field value via Contact API?

Hi @HenrikJanningJuul,

It looks like you’re passing a timestamp in seconds since midnight, not milliseconds since midnight. Most likely what you want to be passing is 1411084800000 not 1411084800.

You can refer to this document for more info: http://developers.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis

0 Upvotes
Not applicable

How to update contact datepicker field value via Contact API?

thanks! Directionally it was good, just had to reverse-engineer value: for me for some reason “midnight” was 03:00:00 , not 00:00:00, probably because of timezones or something, but it was weird and unexpected and error message wasn’t helpful in debugging why my provided value is invalid for API :slight_smile:

anyway, solved issue, thank you!

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

How to update contact datepicker field value via Contact API?

@Antanas_Koncius the reason is that UNIX timestamp represents how many milliseconds have past from unix-time epoch in GMT+0

So you have to adjust for the time zone change depending on how far you are from GMT +0.

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

How to update contact datepicker field value via Contact API?

Hi @Antanas_Koncius

Datepicker properties need to be set using a UNIX formatted timestamp in milliseconds. More details can be found here:

How should timestamps be formatted for HubSpot's APIs?

HubSpot API endpoints accept UNIX formatted timestamps in milliseconds. Most scripting languages have built-in functions or existing libraries that handle time conversion, but you must ensure that your timestamp values are in the correct UNIX...

0 Upvotes