Search code examples
pythonjirajira-pluginjira-rest-apipython-jira

How to access the next page using JIRA -REST-API for python


I am trying to fetch all issues related to a project. When I execute the below code, I get only 50 results. I need to navigate all pages and get all the bugs.Please help

all_issues = jira.search_issues('project=ProjectName')
    each_issue = sorted([issue.key for issue in all_issues])
    for item in each_issue:
        print item

This gives me only 50 issues since the page has default value of 50. I need to get all the issues.


Solution

  • -- Update 18/Oct/2021

    As discovered in the answer below, setting maxResults to False appears to remove the limit on the result set.

    all_issues = jira.search_issues('project=ProjectName', maxResults=False)
    

    -- Original Post

    Try;

    all_issues = jira.search_issues('project=ProjectName', maxResults=50, startAt=50)
    

    The results from the REST API are paged, with the default number of results being 50. You can supply the startAt value to start the results from a point in the result set. By default this value is 0.

    So, your original query would get results 0-49, the query above would get results 50-99 and changing startAt to 100 would get 100-149, and so on.

    You can also increase the value of maxResults to return more results per page. However, this is limited to the max value of jira.search.views.default.max configured in your JIRA instance (set to 1000 by default).

    It is not possible to make the API return all issues without paging. You would have to configure jira.search.views.default.max to a very large value and supply that value as maxResults.