Unable to create company due to "INVALID LONG"

SOLVE
kaoichen
Member

Hi there, 

 

I am trying to create companies with API. However, I ran into this error. 

{"validationResults":[{"isValid":false,"message":"1582128000000.0 was not a valid long.","error":"INVALID_LONG","name":"campaign_start_date"},{"isValid":false,"message":"1585670400000.0 was not a valid long.","error":"INVALID_LONG","name":"campaign_end_date"}],"status":"error","message":"Property values were not valid","correlationId":"649106be-c7da-421c-81a2-03f544fd7532","requestId":"af212da1-d040-4778-92ac-21b8b5e48563"}

 

I understand that dates have to be in milliseconds, and those timestamps are converted in millisecond. I had tried converting them to string or int and none of it worked. 

 

Could you please on pointing me to the right direction?

 

Thanks

0 Upvotes
2 Accepted solutions

Accepted Solutions
WendyGoh
Solution
HubSpot Employee

Hey @kaoichen,

 

When looking to store date properties, the timestamp must be set to midnight UTC e.g. May 1 2015 would be 1430438400000 (01 May 2015 00:00:00 UTC) . Additionally, based on the error message that you shared, I'm able to see that both these timestamps: 1582128000000.0 and 1585670400000.0 isn't a valid timestamp because it contains decimal. 

 

As such, you'd need to ensure that the timestamp value that you're passing over 1. doesn't contain decimal and 2. it is set to midnight UTC. For this, you can learn more on this documentation: How should timestamps be formatted for HubSpot's APIs?

View solution in original post

0 Upvotes
daveroma
Solution
Contributor | Platinum Partner

@kaoichen 

Date properties will only store the date, and must be set to midnight UTC for the date you want.  For example, May 1 2015 would be 1430438400000 (01 May 2015 00:00:00 UTC). If you try to set a value that is not midnight UTC, you will receive an error. In HubSpot, date properties always display the specific date they are set to, regardless of the time zone setting of the account or user.

 

This code should get you close to where you need to be:

 

var dateISO;
// Create date object
var d = new Date('2020-12-17T21:58:01.128Z');
// Set to midnight
d.setUTCHours(0,0,0,0);
// Convert to ISO
dateISO = d.toISOString();
// Create unix timestamp using Date.parse()
document.write(Date.parse(dateISO));

 

 

 

 

View solution in original post

4 Replies 4
WendyGoh
Solution
HubSpot Employee

Hey @kaoichen,

 

When looking to store date properties, the timestamp must be set to midnight UTC e.g. May 1 2015 would be 1430438400000 (01 May 2015 00:00:00 UTC) . Additionally, based on the error message that you shared, I'm able to see that both these timestamps: 1582128000000.0 and 1585670400000.0 isn't a valid timestamp because it contains decimal. 

 

As such, you'd need to ensure that the timestamp value that you're passing over 1. doesn't contain decimal and 2. it is set to midnight UTC. For this, you can learn more on this documentation: How should timestamps be formatted for HubSpot's APIs?

View solution in original post

0 Upvotes
daveroma
Solution
Contributor | Platinum Partner

@kaoichen 

Date properties will only store the date, and must be set to midnight UTC for the date you want.  For example, May 1 2015 would be 1430438400000 (01 May 2015 00:00:00 UTC). If you try to set a value that is not midnight UTC, you will receive an error. In HubSpot, date properties always display the specific date they are set to, regardless of the time zone setting of the account or user.

 

This code should get you close to where you need to be:

 

var dateISO;
// Create date object
var d = new Date('2020-12-17T21:58:01.128Z');
// Set to midnight
d.setUTCHours(0,0,0,0);
// Convert to ISO
dateISO = d.toISOString();
// Create unix timestamp using Date.parse()
document.write(Date.parse(dateISO));

 

 

 

 

View solution in original post

dennisedson
Community Manager

@daveroma digging up questions from the grave, I see 🤣

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
daveroma
Contributor | Platinum Partner

lol

 

😄 ☠️ 👨🏻‍💻 

 

Thanks for marking Accepted