APIs & Integrations

ChrisK1
メンバー

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

解決

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?

0 いいね!
1件の承認済みベストアンサー
ChrisK1
解決策
メンバー

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

解決

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

元の投稿で解決策を見る

0 いいね!
2件の返信
ChrisK1
解決策
メンバー

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

解決

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

0 いいね!
slucas
投稿者

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

解決

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?