Contact date field is always empty after posting to forms API (yes it's in unix time)

SOLVE
Highlighted
New Member

I am trying to use the Forms API to create a contact in HubSpot after someone submits a form on my website. I have it working with the exception of my custom Trial Expires Date field. This is a date picker field I created on a contact records to store the date the trial expires.

The date is always showing empty on the newly created HubSpot contact, however the email that is sent to me (by HubSpot upon a form submission) has the expires date set and displayed correctly.

Here is a small sample of the code I am using to set the date (the expiresDate variable is a UTC DateTime object):

DateTime unixDate = new DateTime(1970, 1, 1, 0, 0, 0, expiresDate.Kind);
long expiresTimestamp = (System.Convert.ToInt64((expiresDate - unixDate).TotalSeconds)) * 1000;
dictFormValues.Add("trial_expires_date", expiresTimestamp.ToString());

Here is a screenshot of the HubSpot email I receive after submission...the date is correct.

Any ideas?

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Solution
New Member

Solved. It was because there was a time component in the expires date. Once I used just the date component it worked ok.

View solution in original post

Reply
0 Upvotes
2 Replies 2
Highlighted
Solution
New Member

Solved. It was because there was a time component in the expires date. Once I used just the date component it worked ok.

View solution in original post

Reply
0 Upvotes
Highlighted
Regular Contributor

Hi, our team is also having trouble passing a trial start and end date via a form.  Pretty much exactly what was described above - it shows in the form submission, but is not passing thru to the contact record, and they are receiving the following error: 

This value wasn’t passed to the contact record. ‘5/7/2019’ isn’t a valid timestamp.

 

They've tried both with and without timestamp.  Can you provide the format you used to solve this?