APIs & Integrations

kaoichen
Member

Unable to create company due to "INVALID LONG"

SOLVE

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
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Unable to create company due to "INVALID LONG"

SOLVE

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
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Unable to create company due to "INVALID LONG"

SOLVE

@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));

 

 

 

 


Dave Roma,
HubSpot CMS Developer

Build a revenue generating website on HubSpot without a developer using The Generator Theme

View solution in original post

4 Replies 4
daveroma
Solution
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Unable to create company due to "INVALID LONG"

SOLVE

@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));

 

 

 

 


Dave Roma,
HubSpot CMS Developer

Build a revenue generating website on HubSpot without a developer using The Generator Theme

dennisedson
HubSpot Product Team
HubSpot Product Team

Unable to create company due to "INVALID LONG"

SOLVE

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

daveroma
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Unable to create company due to "INVALID LONG"

SOLVE

lol

 

😄 ☠️ 👨🏻‍💻 

 

Thanks for marking Accepted  

 

 

 

 

 

 


Dave Roma,
HubSpot CMS Developer

Build a revenue generating website on HubSpot without a developer using The Generator Theme

WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Unable to create company due to "INVALID LONG"

SOLVE

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?

0 Upvotes