Paginating through lists

Have more questions? Submit a request

20 Comments

  • Arlene Salgado
    Comment actions Permalink

    Hi, Charles
    How can I export less than 1000 records with the incremental ticket API??
    I've tried with something like this:
    https://example.zendesk.com/api/v2/exports/tickets.json?start_time=1405469030&per_page=100
    but doesn't works.

    0
  • Dwight Bussman
    Comment actions Permalink

    Hi Arlene,


    There's a few things going on here:



    1. I don't believe the incremental exports endpoint accepts the per_page parameter.



    2. It looks like you're trying to use /api/v2/exports/tickets, which is a different endpoint from the api/v2/incremental/tickets.json used in this article. 

    0
  • Kashish Dup
    Comment actions Permalink

    According to article, the maximum record I can get during ticket's incremental export is 1000. What about other incremental export objects?

    0
  • Dwight Bussman
    Comment actions Permalink

    Hi Kashish,

    Per the incremental exports pagination documentation, all incremental exports pages should return up to 1000 objects.

    "When paginating through an incremental export result set, use the count property to determine when to stop. These endpoints return up to 1000 items per page. If count is less than 1000, then stop paginating. Otherwise, use the next_page URL to get the next page of results."

    0
  • Edward Ionescu
    Comment actions Permalink

    Hi,

    Incremental tickets export doesn't work as expected. You can't export new tickets, only the updated tickets. You can't reach all the pages, for some reason - probably the last page is below 1000 records thus not showing? According to the incremental export, I have no updates on tickets since 05.11 which is impossible. 

    0
  • Bryan - Community Manager
    Comment actions Permalink

    Hi Edward,

    If you're still having this issue, please open a ticket at support@zendesk.com, so we can look at your account in more detail. You should be getting all your tickets assuming the start time that's passed into the API is correct. This is true across other incremental/bulk export type APIs mentioned in this article as well:

    What is the recommended method to regularly export Zendesk Support data?

    0
  • Edward Ionescu
    Comment actions Permalink

    Hi Brian,

    Thank you very much, already did what you suggested. It works fine now, I should have taken into account the "end_time" value and use it as the next start time. I was using a custom start time and that was causing the issue. 

    0
  • Bryan - Community Manager
    Comment actions Permalink

    That's good to know you got things working. Thanks for sharing that back here Edward.

    0
  • Tanawat Oonwattana
    Comment actions Permalink

    Hi,

    Is there anyway that we can call API that can go directly to the last page?

    for example, I am calling this endpoint:

    /api/v2/search.json?query=type:ticket+tags:"order_related"+status<pending&per_page=30&page=1&sort_by=created_at&sort_order=asc

    you can see that I am limiting data to be displayed only 30 items per page.

    and how do I call the API to get me to the last page directly?

    Thank you.

    0
  • Dwight Bussman
    Comment actions Permalink

    Hi Tanawat,

    Would it be possible to set your sort_order=desc instead of ascending, so that the results which would've previously been on the last page would now return on the first page?

    0
  • Azhar
    Comment actions Permalink

    Hi,

    While Paginating through Results of Search API, I am getting a valid next URL as shown below to go to page 11 :

        "facets"null,

        "next_page""https://{}.zendesk.com/api/v2/search.json?page=11&query=type%3Aticket+updated%3E%3D2020-03-15",

        "previous_page""https://{}.zendesk.com/api/v2/search.json?page=9&query=type%3Aticket+updated%3E%3D2020-03-15",

        "count"1674
     But when go for API call to retrieve Page 11, I am getting below error with the response 
    "422 Unprocessable Entity"
    :
    {

        "error""invalid",

        "description""Invalid search: Requested response size was greater than Search Response Limits"

    }

    Ideally, if Page 11 doesn't exist it should have given "next_page" = None on Page 10 output.

    But, it errors out.

    Of course, I can add a check to read Response and terminate the code.

    But, Is this a bug or issue on my end?

    0
  • Dwight Bussman
    Comment actions Permalink

    HeyO Azhar,

    I suspect this issue is related to some search-related changes we rolled out a while back. Thanks for calling out the next_page attribute not being null. I'm going to raise that point to our Devs to see if they can handle this special case more gracefully.

    0
  • sooraj suresh
    Comment actions Permalink

    Hello,


    Is there anyway that we can get more than 1000 rows using the pagination?

    0
  • Dwight Bussman
    Comment actions Permalink

    Hi Sooraj,

    The only endpoint I'm aware of that can return more than 1,000 rows from a single request is the ticket fields endpoint (api/v2/ticket_fields.json), as this endpoint returns the complete list of ticket-fields without paginating.

    All other endpoints for our REST API paginate. The maximum number for most endpoints is 100 records, although some (such as incremental exports) return 1,000 records per request. As such, if you're looking to fetch more than 1,000 records, you will need to make multiple requests for subsequent pages.

    0
  • Support 1i
    Comment actions Permalink

    1. I need to retrieve the ticket details of a specific assignee.
    I tried with search API and got a response as
    {results: Array(100), facets: null, next_page: "https://tracksupport.zendesk.com/api/v2/search.json?page=2&query=assignee%3A361169523923", previous_page: null, count: 9841}

    I am getting only 100 values from this response, even though the count is 9841(1.png). How to get rest of the ticket details?

    I am checking next_page condition also.

    2. I have tried retrieving ticket details of a specific agginee using search api with query 'query=assignee:'+value+'&created>='+startdate+'&created<'+enddate
    but it retrieves the same response if we give only 'query=assignee:'+value
    why I am not able to retrieve the tickets of a specific assignee of given date range? Currently getting current date's data as response for this query.

    0
  • Dwight Bussman
    Comment actions Permalink

    1. Per our Search API documentation

    The Search API returns up to 1,000 results per query, with a maximum of 100 results per page. 

    This means that at most you'll be able to get 1,000 results for the search you've entered, which won't pull all of the records you're looking for. You should be able to make another search request for the url present on the next_page attribute, but 

    Given that you're trying to get information for a particular assignee, I would strongly recommend using the List Tickets endpoint that's designed for just fetching information about tickets assigned to a given agent:

    /api/v2/users/{user_id}/tickets/assigned.json

     

    2. Date ranges

    From your post I'm not quite sure what type of date-formatting you're using for your search query, but here's one that works for me:

    api/v2/search.json?query=type:ticket%20assignee:someone@example.com%20created>2018-01-01

    Please let me know if a similar query helps get you where you need to be. I've seen issues in the past with the use of the ampersand (&) character when our system expects a space or + instead. Please take special note of the formatting examples in this portion of our documentation.

    1
  • Support 1i
    Comment actions Permalink

    Hi @Dwight Bussman

    Thanks for the support.

    I could fix the second problem with your awesome answer and I retrieved the data of the required range(one month). The date format was correct. (&) made the issue.

    See the image of the retrieved data.

    I couldn't resolve my first issue. I could get only 100(0-99) entries out of 1083. I am checking whether the next_page is null or not. if not, I am calling the URL again which is retrieving the same 100 entries out of 1083 instead of the next 100(100-199, 200-299, and so on.). Could you please help me on how to achieve this requirement.

    0
  • Dwight Bussman
    Comment actions Permalink

    Hmm.... that sounds odd to me. Fetching the next_page url should return the next 100 results, not the same set as you're seeing on page 1

    I see that you've already raised a ticket on this matter as well, so I'm going to chat with the agent who's working on your ticket and either myself or that agent will get back to you therein.

    0
  • Support 1i
    Comment actions Permalink

    Hi Dwight Bussman

    With the help of your last answer, I could successfully solve my first issue. I didn't increment the next_page count which was the issue.

    Related to my second question, I have one more doubt. Is it possible to retrieve the tickets based on each project(or view which is highlighted in the image) as we retrieved data based on the assignee? 

    Thanks in advance

    0
  • Dwight Bussman
    Comment actions Permalink

    Let's continue this discussion within the ticket you have going with support. I have some questions specific to your account and that's a better forum so we're not spamming folks subscribed to this article with our conversation. Please do not respond again here unless there's a larger point you'd prefer to discuss with the group at large; please reply in the ticket. Thanks

    0

Please sign in to leave a comment.

Powered by Zendesk