APIs & Integrations

DRead
Colaborador

Events API Error

resolver

 

const eventType = 'pe23232_xyz';
const contactId = event.object.objectId;

const response = await hubspotClient.events.eventsApi.getPage(
null,
null,
'contact',
contactId,
eventType,
null,
null,
1,
['-occurredAt'],
undefined,
);



status: error

message: Invalid input JSON on line -1, column -1: Cannot construct instance of `com.hubspot.apiutils.core.models.time.Iso8601Instant`, problem: Failed to parse {{ timestamp }} as an ISO8601 string



x-trace: 2BE1D0C8D83B574BC80E3F8504A788F0434370B83D000000000000000000



If I fallback to the direct API call using the SDK, it works



const response = await hubspotClient.apiRequest({
method: 'GET',
path: `/events/v3/events`,
qs: {
eventType,
objectType: 'contact',
objectId: contactId,
limit: 1,
sort: ['-occurredAt'],
},
});

const events = await response.json();

 

 

0 Me gusta
2 Soluciones aceptadas
DRead
Solución
Colaborador

Events API Error

resolver

Found the issue, if I replace all nulls with undefined it works.

Ver la solución en mensaje original publicado

0 Me gusta
DRead
Solución
Colaborador

Events API Error

resolver

The last argument to the function is a "Context" parameter not a timestamp.

Ver la solución en mensaje original publicado

0 Me gusta
3 Respuestas 3
DRead
Solución
Colaborador

Events API Error

resolver

Found the issue, if I replace all nulls with undefined it works.

0 Me gusta
himanshurauthan
Líder intelectual | Partner nivel Elite
Líder intelectual | Partner nivel Elite

Events API Error

resolver

Hello @DRead 

Make sure you are providing a valid ISO8601 formatted timestamp value for the {{ timestamp }} placeholder. The timestamp should be in the format YYYY-MM-DDTHH:mm:ssZ, where YYYY represents the year, MM represents the month, DD represents the day, HH represents the hour, mm represents the minute, ss represents the second, and Z represents the timezone offset.

you can provide the timestamp as a string in the format '2023-05-19T12:00:00Z'.

Here's an updated code snippet for the HubSpot Events API call using the SDK

const eventType = 'pe23232_xyz';
const contactId = event.object.objectId;
const timestamp = '2023-05-19T12:00:00Z'; // Replace this with a valid ISO8601 timestamp

const response = await hubspotClient.events.eventsApi.getPage(
  null,
  null,
  'contact',
  contactId,
  eventType,
  null,
  null,
  1,
  ['-occurredAt'],
  timestamp
);

const events = response.results; // Assuming the response object has a `results` property containing the events

console.log(events);


Make sure to replace '2023-05-19T12:00:00Z' with the actual valid timestamp value in your code.

Digital Marketing & Inbound Expert In Growth Hacking Technology
0 Me gusta
DRead
Solución
Colaborador

Events API Error

resolver

The last argument to the function is a "Context" parameter not a timestamp.

0 Me gusta