How to update contact datepicker field value via Contact API?

contacts

#1

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


#2

Hi @Antanas_Koncius

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


#3

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!


#4

@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.


#5

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


#6

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


#7

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

/Henrik


#8

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

strange…