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();
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.
The last argument to the function is a “Context” parameter not a timestamp.
Found the issue, if I replace all nulls with undefined it works.