APIs & Integrations

ChrisK1
Mitglied

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

lösung

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 Upvotes
1 Akzeptierte Lösung
ChrisK1
Lösung
Mitglied

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

lösung

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

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
2 Antworten
ChrisK1
Lösung
Mitglied

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

lösung

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

0 Upvotes
slucas
Mitwirkender/Mitwirkende

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

lösung

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?