APIs & Integrations

kaoichen
Miembro

Unable to create company due to "INVALID LONG"

resolver

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 Me gusta
2 Soluciones aceptadas
WendyGoh
Solución
HubSpot Employee
HubSpot Employee

Unable to create company due to "INVALID LONG"

resolver

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?

Ver la solución en mensaje original publicado

0 Me gusta
daveroma
Solución
Colaborador líder | Partner nivel Platinum
Colaborador líder | Partner nivel Platinum

Unable to create company due to "INVALID LONG"

resolver

@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

Ver la solución en mensaje original publicado

4 Respuestas 4
daveroma
Solución
Colaborador líder | Partner nivel Platinum
Colaborador líder | Partner nivel Platinum

Unable to create company due to "INVALID LONG"

resolver

@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
Equipo de producto de HubSpot
Equipo de producto de HubSpot

Unable to create company due to "INVALID LONG"

resolver

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

daveroma
Colaborador líder | Partner nivel Platinum
Colaborador líder | Partner nivel Platinum

Unable to create company due to "INVALID LONG"

resolver

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
Solución
HubSpot Employee
HubSpot Employee

Unable to create company due to "INVALID LONG"

resolver

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 Me gusta