<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Events API Error in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/795670#M64112</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 May 2023 15:36:44 GMT</pubDate>
    <dc:creator>DRead</dc:creator>
    <dc:date>2023-05-18T15:36:44Z</dc:date>
    <item>
      <title>Events API Error</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/795670#M64112</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 15:36:44 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/795670#M64112</guid>
      <dc:creator>DRead</dc:creator>
      <dc:date>2023-05-18T15:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Events API Error</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/796098#M64151</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/360246"&gt;@DRead&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;you can provide the timestamp as a string in the format '2023-05-19T12:00:00Z'.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here's an updated code snippet for the HubSpot Events API call using the SDK&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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);
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Make sure to replace '2023-05-19T12:00:00Z' with the actual valid timestamp value in your code.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 09:10:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/796098#M64151</guid>
      <dc:creator>himanshurauthan</dc:creator>
      <dc:date>2023-05-19T09:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Events API Error</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/796256#M64163</link>
      <description>&lt;P&gt;Found the issue, if I replace all nulls with undefined it works.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 14:47:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/796256#M64163</guid>
      <dc:creator>DRead</dc:creator>
      <dc:date>2023-05-19T14:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Events API Error</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/796257#M64164</link>
      <description>&lt;P&gt;The last argument to the function is a "Context" parameter not a timestamp.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 14:47:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Events-API-Error/m-p/796257#M64164</guid>
      <dc:creator>DRead</dc:creator>
      <dc:date>2023-05-19T14:47:50Z</dc:date>
    </item>
  </channel>
</rss>

