13

I am using Jira REST API to get all the Issues in Jira for a specific Project. I don't want to have maxResults=50, which is the default. I just want to retrieve all issues for the project. Here is my command:

{ my $result = `curl -D- -u $usernameData:$passwordData -X GET -H "Content-Type: application/json" "http://jira.alm.mentorg.com:8080/rest/api/2/search?jql=project=HDS&maxResults=1000&fields=summary"`;}

I set maxResults=1000 and if I remove it, it will be set by default to 50! I just want to get all the Issues without having to worry about the maxResults. Can anyone help me with that?

Josh Withee
  • 9,922
  • 3
  • 44
  • 62
Shereen Hussein
  • 175
  • 1
  • 2
  • 9

4 Answers4

12
  1. Set the maxResults to a ridiculously high value e.g. 5000
  2. Make an extra call just to fetch the total records quickly, without actually fetching any content

    http://jira.alm.mentorg.com:8080/rest/api/2/search?jql=project=HDS&maxResults=0

Neo
  • 304
  • 1
  • 7
  • 2
    "The maximum number of users to return (defaults to 50). The maximum allowed value is 1000. If you specify a value that is higher than this number, your search results will be truncated." https://docs.atlassian.com/jira/REST/latest/#api/2/groupuserpicker-findUsersAndGroups – Thomas Jun 07 '16 at 09:44
5

Yes, of course we can help. :D The answer is you cannot NOT worry about the maxResult field. There should however be another field in the return of the REST API that shows the total count. I don't remember what it was exactly but maybe total?

This is an API feature and you will have to manage it. 'pagination' is there to optimize data volumes and flow. Check the JIRA REST API Docs.

Borislav Sabev
  • 4,776
  • 1
  • 24
  • 30
4

I have just tried to pass -1 value to maxResults and got all the issues for the specific project. Not sure if this is a bug, which will be removed in next releases, but for now it works.. I am using JIRA v.6.2.2#6258 Call: /rest/api/2/search?jql=project=[project_ID]&fields=*none&maxResults=-1

So the next step would be to count returned array

Boris Mocialov
  • 3,439
  • 2
  • 28
  • 55
  • I see, that using -1 as maxResults defaults to 1000. I did try with project that had over 5000 issues in it. – Lauri Feb 10 '15 at 10:10
  • @Lauri thank you for telling. I guess my answer is wrong then – Boris Mocialov Feb 10 '15 at 12:37
  • @Boris it could be, that in your jira maxResults is configured to be something else than 1000 and that is why you got all your issues returned. However I don't recollect any way to get ALL the issues without paging, in case the number of issues exceeds _maxResults_ configured in your JIRA – Lauri Feb 16 '15 at 09:15
1

You are able to change the maxResults if you are not a cloud user:

https://confluence.atlassian.com/jirakb/changing-maxresults-parameter-for-jira-rest-api-779160706.html

Elepferd
  • 156
  • 4