APIs & Integrations

kaoichen
メンバー

Unable to create company due to "INVALID LONG"

解決

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 いいね!
2件の承認済みベストアンサー
WendyGoh
解決策
HubSpot Employee
HubSpot Employee

Unable to create company due to "INVALID LONG"

解決

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 いいね!
daveroma
解決策
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

Unable to create company due to "INVALID LONG"

解決

@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

元の投稿で解決策を見る

4件の返信
daveroma
解決策
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

Unable to create company due to "INVALID LONG"

解決

@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製品開発チーム
HubSpot製品開発チーム

Unable to create company due to "INVALID LONG"

解決

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

daveroma
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

Unable to create company due to "INVALID LONG"

解決

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
解決策
HubSpot Employee
HubSpot Employee

Unable to create company due to "INVALID LONG"

解決

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 いいね!