Fetch coversation without limit

  • 1 August 2018
  • 4 replies
  • 62 views

It seems that API to fetch the ticket conversation will return the first 30 conversation, I need all the conversation without setting the page number in the API url, is there any way to get all the conversation



This topic has been closed for comments

4 replies

Just loop through all of the pages in your app. Response pagination is pretty common.


what if i dont know the number of pages , how will i get all the conversation?



There's a few different ways, but here's a simple one:


1. Hit the endpoint with pageNumber=1

2. If the response has a length = 30, hit the endpoint with pageNumber++

3. If the response has a length < 30, stop.


Userlevel 4
Badge +12

Hello,


When you hit the API endpoint, the server returns the response along with the 'link' header. It indicates if the next page exists and provides the url of the page. You can adjust your script so that the value of the link header is taken into consideration and the API call gets updated accordingly. Sample link header:


"link":< https://domain.freshdesk.com/api/v2/tickets?filter=all_tickets&page=2>;rel="next"


Cheers!