HubSpot date field update failing with timestamp value

I’m trying to update a date property in HubSpot using their API but getting validation errors. I have a contact property set up as a “Date Picker” type in HubSpot. In my C# code, I’m using a nullable double to store the timestamp value.

[JsonProperty(PropertyName = "registration_date")]
public double? registrationDate { get; set; }

I convert my date to UTC timestamp before sending it to HubSpot like this:

contact.properties.registrationDate = ConvertToUTCTimestamp(Convert.ToDateTime(userInfo.registrationDate.ToShortDateString()));

public static double ConvertToUTCTimestamp(System.DateTime dateTime)
{
    dateTime = System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
    var timestamp = ((DateTimeOffset)dateTime).ToUnixTimeMilliseconds();
    return timestamp;
}

The JSON payload looks correct to me:
{“properties”:{“registration_date":1601856000000.0,“firstname”:“John”,“lastname”:“Smith”,“email”:"[email protected]”,“phone”:“5551234567”}}

But HubSpot returns this error:

{"status":"error","message":"Property values were not valid: [{\"isValid\":false,\"message\":\"1601856000000.0 was not a valid long.\",\"error\":\"INVALID_LONG\",\"name\":\"registration_date\"}]","correlationId":"abc123","category":"VALIDATION_ERROR"}

When I change the HubSpot property to text type it works fine, but I need it as a date field. What am I doing wrong with the timestamp format?

hubspot needs a long not double for timestamps. make sure to cast it like this - public long? registrationDate { get; set; } that should solve your validation issue.

Had this exact issue with HubSpot contact properties last month. Your ConvertToUTCTimestamp method returns a double, but HubSpot’s date picker fields need long integers for Unix timestamps. That .0 in your JSON is what’s causing the INVALID_LONG error. Don’t just change the property to long? - update your conversion method to return long instead of double. This stops any casting problems later. Also validate your DateTime input first since HubSpot gets picky about null dates or dates outside their range.

yeah, that’s a classic hubspot gotcha - the decimal point is what’s breaking it. hubspot’s really picky about data types, so even tho your timestamp value is right, it won’t accept it. switch your return type from double to long in the conversion method and you should be good to go.

The error’s pretty clear—HubSpot wants a long integer but you’re sending a double with decimals. I’ve hit this same issue with their properties API. Your method’s returning a double instead of long. Just cast it: return (long)timestamp; That’ll fix the validation error. Also make sure your DateTime conversion isn’t adding precision issues. Using DateTimeOffset from the start might save you headaches later.

Your timestamp conversion returns a double, but HubSpot needs a long integer. I hit this same issue last year with their contacts API. That decimal notation (1601856000000.0) in your JSON is what’s causing the validation error. Change your property to public long? registrationDate { get; set; } and update your conversion method to return long instead of double. You can also use ToUnixTimeMilliseconds() directly on DateTimeOffset - skip the double conversion entirely. HubSpot’s date picker fields won’t validate unless you send clean integers without decimals.