APIs & Integrations

itaytur
Member

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

i'm working with the AJAX support to send forms, and when looking at the date field at one of the forms, at the form's submissions it says the title error (This value wasn't passed to the contact record...).

 

i looked into it and tried the offered solutions from previous posts: 

this is the first version: 

let nowDateTime = new Date().getTime();

i tried send the date after setting it to midnight, but it still got the error.

let nowDateTime = new Date().getTime();
nowDateTime = new Date().setHours(0,0,0,0);

i tried to look for the type to see what the type the form expect. didn't found it. so i don't know for sure if it's date or dateTime but, it's date picker so it's date based on the docs (i guess, still didn't understood how to know if it's dateTime). 

what this sentence mean : "The only way to create a datetime property is by using the APIs"? link to the docs 

 

anther thing is that the same code that create the field being sent, works for other forms.

i tried to compare the form property with other and didnt found anything different.

 

hope you could help me, thx

0 Upvotes
2 Accepted solutions
itaytur
Solution
Member

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

yes the UTC was the problem.

i changed it to this and it worked! 

const updateDate = new Date();
updateDate.setUTCHours(0,0,0,0);
const nowDateTime = updateDate.getTime();

thank you ! if i want the field to be dateTime how can i do it ? and how do i know if it is dateTime or just date?

View solution in original post

IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

Hi, @itaytur.

 

Glad to hear it!

 

You can check a contact property's type by querying this endpoint with the property's internal name. In this case, your request URL would be:

 

https://api.hubapi.com/properties/v1/contacts/properties/named/dpsaddtravelerdetailsdate

 

Similarly, you change a custom contact property to "type": "datetime" with this endpoint.

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
8 Replies 8
IsaacTakushi
HubSpot Employee
HubSpot Employee

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

Welcome, @itaytur.

 

Could you share complete sample JSON you're submitting to the v3 forms endpoint? I'd like to see the value of your nowDateTime variable. Per this article, it should be a millisecond timestamp corresponding to midnight UTC if the property is a date-type property, which it sounds like.

 

Also if you could share your form GUID (for security, no need to share your Hub ID).

Isaac Takushi

Associate Certification Manager
0 Upvotes
itaytur
Member

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

hi issac,

thank you for replying.

 

this is the field that uses the nowDateTime value: 

 

{
      "name": "dpsaddtravelerdetailsdate",
      "value": 1578434400000
    }

this is the entire JSON being sent: 

 

{
  "fields": [
    {
      "name": "dpsbrand",
      "value": "hotelopia"
    },
    {
      "name": "dpsplatform",
      "value": "Web"
    },
    {
      "name": "dpsbrowser",
      "value": "Chrome 77"
    },
    {
      "name": "dpschannel",
      "value": "Publish"
    },
    {
      "name": "dpslocale",
      "value": "en-uk"
    },
    {
      "name": "dpsmarketcode",
      "value": "gb"
    },
    {
      "name": "dpscurrency_code",
      "value": "GBP"
    },
    {
      "name": "dpsaddtravelerdetailscheckin",
      "value": 1578614400000
    },
    {
      "name": "dpsaddtravelerdetailscheckout",
      "value": 1579132800000
    },
    {
      "name": "dpsaddtravelerdetailsadults",
      "value": 2
    },
    {
      "name": "dpsaddtravelerdetailschildren",
      "value": 0
    },
    {
      "name": "dpsaddtravelerdetailsdestinationid",
      "value": "PAR"
    },
    {
      "name": "dpsaddtravelerdetailsdestinationdescription",
      "value": "Paris"
    },
    {
      "name": "dpsaddtravelerdetailsdeeplink",
      "value": "http://localhost/gb/en-uk/hotels/checkout/?bookingId=P25127213"
    },
    {
      "name": "dpsaddtravelerdetailsdate",
      "value": 1578434400000
    },
    {
      "name": "dpsaddtravelerdetailsnumofnights",
      "value": 6
    },
    {
      "name": "dpsaddtravelerdetailsstarlevel",
      "value": ""
    },
    {
      "name": "dpsaddtravelerdetailshotelid",
      "value": 678115
    },
    {
      "name": "dpsaddtravelerdetailshotelname",
      "value": "RESIDHOME SAINT-OUEN"
    },
    {
      "name": "dpsaddtravelerdetailsavgnightprice",
      "value": ""
    },
    {
      "name": "dpsaddtravelerdetailsroomtypename",
      "value": "STUDIO STANDARD"
    },
    {
      "name": "dpsaddtravelerdetailsroomtypeid",
      "value": "STU.ST"
    },
    {
      "name": "dpsaddtravelerdetailsrooms",
      "value": 1
    },
    {
      "name": "dpsaddtravelerdetailstotalprice",
      "value": 434.31
    },
    {
      "name": "firstname",
      "value": "fds"
    },
    {
      "name": "lastname",
      "value": "fdsf"
    },
    {
      "name": "email",
      "value": "ittur@hotelbeds.com"
    },
    {
      "name": "phone",
      "value": "+44 6546 54646"
    },
    {
      "name": "dpsaddtravelerdetailsimageurl",
      "value": "67/678115/678115a_hb_a_001.jpg"
    }
  ]
}

and i change the code the creates the the nowDateTime value, because the previos one was translated to yestrday midnight: 

 

const updateDate = new Date();
updateDate.setHours(24,0,0,0);
const nowDateTime = updateDate.getTime();

 

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

Thanks for sharing, @itaytur.

 

I confirmed that the dpsaddtravelerdetailsdate property is a date-type property in your account ending in 0425.

 

It expects a UNIX millisecond timestamp at midnight UTC/GMT, but 1578434400000 actually corresponds to 7 January 2020 at 22:00:00, not midnight (I used this tool).

 

Are you accounting for your own time zone?

Isaac Takushi

Associate Certification Manager
0 Upvotes
itaytur
Solution
Member

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

yes the UTC was the problem.

i changed it to this and it worked! 

const updateDate = new Date();
updateDate.setUTCHours(0,0,0,0);
const nowDateTime = updateDate.getTime();

thank you ! if i want the field to be dateTime how can i do it ? and how do i know if it is dateTime or just date?

IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

Hi, @itaytur.

 

Glad to hear it!

 

You can check a contact property's type by querying this endpoint with the property's internal name. In this case, your request URL would be:

 

https://api.hubapi.com/properties/v1/contacts/properties/named/dpsaddtravelerdetailsdate

 

Similarly, you change a custom contact property to "type": "datetime" with this endpoint.

Isaac Takushi

Associate Certification Manager
0 Upvotes
itaytur
Member

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

great! 

thx again Issac 🙂

itaytur
Member

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

Hi issac,

thx for replying.

 

the field that uses the nowDateTime value: 

{
      "name": "dpsaddtravelerdetailsdate",
      "value": 1578434400000
    }

the JSON being sent: 

 

{
  "fields": [
    {
      "name": "dpsbrand",
      "value": "hotelopia"
    },
    {
      "name": "dpsplatform",
      "value": "Web"
    },
    {
      "name": "dpsbrowser",
      "value": "Chrome 77"
    },
    {
      "name": "dpschannel",
      "value": "Publish"
    },
    {
      "name": "dpslocale",
      "value": "en-uk"
    },
    {
      "name": "dpsmarketcode",
      "value": "gb"
    },
    {
      "name": "dpscurrency_code",
      "value": "GBP"
    },
    {
      "name": "dpsaddtravelerdetailscheckin",
      "value": 1578614400000
    },
    {
      "name": "dpsaddtravelerdetailscheckout",
      "value": 1579132800000
    },
    {
      "name": "dpsaddtravelerdetailsadults",
      "value": 2
    },
    {
      "name": "dpsaddtravelerdetailschildren",
      "value": 0
    },
    {
      "name": "dpsaddtravelerdetailsdestinationid",
      "value": "PAR"
    },
    {
      "name": "dpsaddtravelerdetailsdestinationdescription",
      "value": "Paris"
    },
    {
      "name": "dpsaddtravelerdetailsdeeplink",
      "value": "http://localhost/gb/en-uk/hotels/checkout/?bookingId=p1111111"
    },
    {
      "name": "dpsaddtravelerdetailsdate",
      "value": 1578434400000
    },
    {
      "name": "dpsaddtravelerdetailsnumofnights",
      "value": 6
    },
    {
      "name": "dpsaddtravelerdetailsstarlevel",
      "value": ""
    },
    {
      "name": "dpsaddtravelerdetailshotelid",
      "value": 333333
    },
    {
      "name": "dpsaddtravelerdetailshotelname",
      "value": "RESIDHOME SAINT-OUEN"
    },
    {
      "name": "dpsaddtravelerdetailsavgnightprice",
      "value": ""
    },
    {
      "name": "dpsaddtravelerdetailsroomtypename",
      "value": "STUDIO STANDARD"
    },
    {
      "name": "dpsaddtravelerdetailsroomtypeid",
      "value": "STU.ST"
    },
    {
      "name": "dpsaddtravelerdetailsrooms",
      "value": 1
    },
    {
      "name": "dpsaddtravelerdetailstotalprice",
      "value": 434.31
    },
    {
      "name": "firstname",
      "value": "fds"
    },
    {
      "name": "lastname",
      "value": "fdsf"
    },
    {
      "name": "email",
      "value": "TEST@TEST.com"
    },
    {
      "name": "phone",
      "value": "+44 6546 54646"
    },
    {
      "name": "dpsaddtravelerdetailsimageurl",
      "value": "67/678115/678115a_hb_a_001.jpg"
    }
  ]
}

the code creating the value ( a little different from the how i implemented it in the original post, because it was translated to yesterday midnight) :

 

const updateDate = new Date();
updateDate.setHours(24,0,0,0);
const nowDateTime = updateDate.getTime();
0 Upvotes
itaytur
Member

Date error: This value wasn't passed to the contact record. '1/6/2020' isn't a valid timestamp.

SOLVE

 

the field object that uses the nowDateTime value: 

 

{
      "name": "dpsaddtravelerdetailsdate",
      "value": 1578434400000
    }

the JSON being sent: 

 



{ "fields": [ { "name": "dpsbrand", "value": "hotelopia" }, { "name": "dpsplatform", "value": "Web" }, { "name": "dpsbrowser", "value": "Chrome 77" }, { "name": "dpschannel", "value": "Publish" }, { "name": "dpslocale", "value": "en-uk" }, { "name": "dpsmarketcode", "value": "gb" }, { "name": "dpscurrency_code", "value": "GBP" }, { "name": "dpsaddtravelerdetailscheckin", "value": 1578614400000 }, { "name": "dpsaddtravelerdetailscheckout", "value": 1579132800000 }, { "name": "dpsaddtravelerdetailsadults", "value": 2 }, { "name": "dpsaddtravelerdetailschildren", "value": 0 }, { "name": "dpsaddtravelerdetailsdestinationid", "value": "PAR" }, { "name": "dpsaddtravelerdetailsdestinationdescription", "value": "Paris" }, { "name": "dpsaddtravelerdetailsdeeplink", "value": "http://localhost/gb/en-uk/hotels/checkout/?bookingId=P1234567" }, { "name": "dpsaddtravelerdetailsdate", "value": 1578434400000 }, { "name": "dpsaddtravelerdetailsnumofnights", "value": 6 }, { "name": "dpsaddtravelerdetailsstarlevel", "value": "" }, { "name": "dpsaddtravelerdetailshotelid", "value": 333333 }, { "name": "dpsaddtravelerdetailshotelname", "value": "RESIDHOME SAINT-OUEN" }, { "name": "dpsaddtravelerdetailsavgnightprice", "value": "" }, { "name": "dpsaddtravelerdetailsroomtypename", "value": "STUDIO STANDARD" }, { "name": "dpsaddtravelerdetailsroomtypeid", "value": "STU.ST" }, { "name": "dpsaddtravelerdetailsrooms", "value": 1 }, { "name": "dpsaddtravelerdetailstotalprice", "value": 434.31 }, { "name": "firstname", "value": "fds" }, { "name": "lastname", "value": "fdsf" }, { "name": "email", "value": "test@test.com" }, { "name": "phone", "value": "+44 6546 54646" }, { "name": "dpsaddtravelerdetailsimageurl", "value": "67/678115/678115a_hb_a_001.jpg" } ] }

this is how i set it to midnight (a little different from how i posted in the original post, because after checking the submission, it was translated to yesterday midnight):

 

 

 const updateDate = new Date();
 updateDate.setHours(24,0,0,0);
 const nowDateTime = updateDate.getTime();

the form GUID is: 6256018a-b178-45ed-b528-2c1ffb70d011

 

 

0 Upvotes