<?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 Re: Service Ticket List Order in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Service-Ticket-List-Order/m-p/799951#M64425</link>
    <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/575014"&gt;@Phwilson17&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for your question!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The short(ish) answer — To retrieve &lt;EM&gt;all&lt;/EM&gt; tickets, you have to make multiple requests using the value returned for &lt;CODE&gt;after&lt;/CODE&gt; to get all your Tickets. The HubSpot API uses this kind of pagination to ensure performance and stability, so there isn't a way to retrieve all tickets in a single call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To sort the tickets by date from newest to oldest, you'll need to use the &lt;A href="https://developers.hubspot.com/docs/api/crm/search#sort-search-results" target="_blank" rel="noopener"&gt;Search API endpoint for Tickets&lt;/A&gt;. The &lt;CODE&gt;GET /crm/v3/objects/tickets&lt;/CODE&gt; endpoint you're using does not support sorting. Here's an example of how to sort using the Search API:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
  "filterGroups": [],
  "sorts": [
    {
      "propertyName": "createdate",
      "direction": "DESCENDING"
    }
  ]
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You'd POST this payload to &lt;/SPAN&gt;&lt;CODE&gt;/crm/v3/objects/tickets/search&lt;/CODE&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Have fun building! — Jaycee&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 28 May 2023 19:59:19 GMT</pubDate>
    <dc:creator>Jaycee_Lewis</dc:creator>
    <dc:date>2023-05-28T19:59:19Z</dc:date>
    <item>
      <title>Service Ticket List Order</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Service-Ticket-List-Order/m-p/799586#M64404</link>
      <description>&lt;P&gt;I'm trying to use the retrieve ticket get request with&amp;nbsp;/crm/v3/objects/tickets but noticed that it only returns a small amount of tickets at once and from oldest to newest. It does provide a link to get the next batch but I'd rather not have to make call after call as I work my way to the most recent tickets. Is there a way to get the list to return from newest to oldest, or possibly just get all tickets in a single call?&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 15:43:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Service-Ticket-List-Order/m-p/799586#M64404</guid>
      <dc:creator>Phwilson17</dc:creator>
      <dc:date>2023-05-26T15:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Service Ticket List Order</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Service-Ticket-List-Order/m-p/799951#M64425</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/575014"&gt;@Phwilson17&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for your question!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The short(ish) answer — To retrieve &lt;EM&gt;all&lt;/EM&gt; tickets, you have to make multiple requests using the value returned for &lt;CODE&gt;after&lt;/CODE&gt; to get all your Tickets. The HubSpot API uses this kind of pagination to ensure performance and stability, so there isn't a way to retrieve all tickets in a single call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To sort the tickets by date from newest to oldest, you'll need to use the &lt;A href="https://developers.hubspot.com/docs/api/crm/search#sort-search-results" target="_blank" rel="noopener"&gt;Search API endpoint for Tickets&lt;/A&gt;. The &lt;CODE&gt;GET /crm/v3/objects/tickets&lt;/CODE&gt; endpoint you're using does not support sorting. Here's an example of how to sort using the Search API:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
  "filterGroups": [],
  "sorts": [
    {
      "propertyName": "createdate",
      "direction": "DESCENDING"
    }
  ]
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You'd POST this payload to &lt;/SPAN&gt;&lt;CODE&gt;/crm/v3/objects/tickets/search&lt;/CODE&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Have fun building! — Jaycee&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 19:59:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Service-Ticket-List-Order/m-p/799951#M64425</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-05-28T19:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Service Ticket List Order</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Service-Ticket-List-Order/m-p/803339#M64628</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/575014"&gt;@Phwilson17&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure, there are a few ways to get all tickets in a single call or to get the list to return from newest to oldest.&lt;/P&gt;
&lt;P&gt;**Get all tickets in a single call**&lt;/P&gt;
&lt;P&gt;To get all tickets in a single call, you can use the following parameters in the request URL:&lt;/P&gt;
&lt;P&gt;```&lt;BR /&gt;&amp;amp;offset=0&lt;BR /&gt;&amp;amp;limit=1000&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;The `offset` parameter specifies the starting point for the results, and the `limit` parameter specifies the maximum number of results to return. In this case, the request will return all tickets, starting with the most recent.&lt;/P&gt;
&lt;P&gt;**Get the list to return from newest to oldest**&lt;/P&gt;
&lt;P&gt;To get the list to return from newest to oldest, you can use the following parameter in the request URL:&lt;/P&gt;
&lt;P&gt;```&lt;BR /&gt;&amp;amp;sort=created_at desc&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;The `sort` parameter specifies the order of the results, and the `desc` keyword specifies that the results should be sorted in descending order. In this case, the request will return the tickets in order from newest to oldest.&lt;/P&gt;
&lt;P&gt;**Make multiple calls to get all tickets**&lt;/P&gt;
&lt;P&gt;If you don't want to use the `offset` and `limit` parameters, you can make multiple calls to the API to get all tickets. In this case, you would use the `hasMore` property in the response to determine if there are more tickets to get. If `hasMore` is true, you would use the `nextOffset` property to get the offset for the next request.&lt;/P&gt;
&lt;P&gt;Here is an example of how to make multiple calls to get all tickets:&lt;/P&gt;
&lt;P&gt;```&lt;BR /&gt;// Get the first batch of tickets&lt;BR /&gt;const response = await hubspot.crm.tickets.get({&lt;BR /&gt;limit: 100,&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;// Check if there are more tickets&lt;BR /&gt;if (response.hasMore) {&lt;BR /&gt;// Get the next batch of tickets&lt;BR /&gt;const nextOffset = response.nextOffset;&lt;BR /&gt;await hubspot.crm.tickets.get({&lt;BR /&gt;limit: 100,&lt;BR /&gt;offset: nextOffset,&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;This code will get all tickets, in batches of 100 tickets at a time.&lt;/P&gt;
&lt;P&gt;Hope this will helps you out. Please mark it as Solution Accepted to help other Community member.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 06:40:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Service-Ticket-List-Order/m-p/803339#M64628</guid>
      <dc:creator>GRajput</dc:creator>
      <dc:date>2023-06-06T06:40:13Z</dc:date>
    </item>
  </channel>
</rss>

