How to get more than 50 issues with search API

Deleted user June 12, 2016

I am trying to use JIRA REST Search API to get issues. However API returns me only 50 issues. I tried using startAt and maxResults. However I am getting error 'Field 'startAt' does not exist or you do not have permission to view it." What should I do to get all the issues using JIRA Rest API

4 answers

7 votes
Igor Cherepanov October 26, 2017

today I discovered that maxResults does not work anymore... even if I assign to maxResults a number bigger than 100, I get always issues from 0 until 99 

Jacob Thomas October 30, 2017

Below is based on the response received from a Support ticket:

The /rest/api/2/search endpoint has been limited to 100 results , as you can see at: JRACLOUD-67570: JIRA Cloud REST API /rest/api/latest/search?maxResults=1000 is returning only 100 results

Unfortunately, this limit isn't configurable, you'll need to rely on pagination to retrieve the desired number of results

Like Rajesh Bhardwaj likes this
3 votes
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 12, 2016

Based on the error I assume that you try to pass startAt as a field. The format of GET params should be as following:

rest/api/2/search?jql=SOME_JQL&fields=summary,duedate,issuetype&startAt=51
1 vote
stratejos [stratejos.ai] June 15, 2016

You need to pass maxResults=500 as one of the query parameters. Where 500 is the maximum number of results you want back.

Here is an example call I use to get issues from JIRA OnDemand and JIRA Server via the REST API. It returns as many results as I need.

/search?jql=project%3DSTRATEJOS&maxResults=5000&fields=*navigable,worklog

If you use this then you don't need startAt (it becomes optional).

David Leal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2019

I tried it, but it does not work. I guess maxResults can apply only if it is less than 100 records, because Altassian imposed this maximum number of records. See JIRACloud-67570. Please if you know any workaround for obtaining 5000 records at once, please share it. Thanks

Like Ulyana Vorobeva likes this
georgiossalon February 19, 2019

I wrote a do-while loop which is working for me :)

int startAt = 0;
int maxResults = 50;
int queryOutputItemsCount = 0;
do {
try{

HttpResponse<JsonNode> response = Unirest.get("https://your-domain.atlassian.net/rest/agile/1.0/sprint/{sprintId}/?startAt=" +startAt")
.basicAuth("email@example.com", "<api_token>")
.header("Accept", "application/json")
.asJson();

JsonNode jsonNode = response.getBody();
JSONObject jsonObjectType = jsonNode.getObject();
String typeKey = "values";
org.json.JSONArray jsonArrayType = jsonObjectType.getJSONArray(typeKey);
queryOutputItemsCount = jsonArrayType.length();

// write your code here


startAt=startAt+maxResults;
} catch (UnirestException e) {
e.printStackTrace();
}
} while (queryOutputItemsCount>=maxResults);

within the loop, I am continually making JQL statements and getting the length of the statement back. If the statements length is smaller than the maxResults=50 then it means that I got all of them back. Else startAt = startAt+maxResults;

 

Hope it helps.

Like # people like this
Rodolfo So May 17, 2019

May i know how you run this command in jira?

Like Danilo Castro Borges likes this
georgiossalon May 18, 2019

@Rodolfo So 

I did not write this code in jira. I used a REST API, which is a connector to jira from "outside". The code I integrated in a java programm.

David Leal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2019

@Rodolfo So Yes, I did something similar but using VBA, the problem is that for a high number of issues the performance of the process is affected. I implemented a pagination strategy for both: 1) JIRA REST API with 100 limit and 2) Jira export download with 1000 limit.  I implemented the solution using VBA. For downloading 4K records 1) took me more than 5 minutes and under option 2) I was able to download and consolidate all the issues into one file in less than a minute. 

For a high number of records (more than 1K) I would not recommend this method unless Atlassian increases the limit from 100 to something really higher. At least this is my experience under VBA.

Like winiz likes this
Matt Flaherty January 10, 2020

You can get all results in one call by using either an arbitrarily large value for maxResults or using a value of -1. For example:

/search?jql=[whatever your JQL is]&maxResults=-1
Like # people like this
Wesley Lee March 4, 2020

Thanks Matt! Setting it to -1 worked for me, setting it to a large number still capped at 50 though.

Andrew Findlay July 24, 2020

Great solution, worked for me as well! thanks!!

snalluri November 16, 2020

Setting maxResults=-1 is returning me only 100 results. It doesn't work for me. 

Like # people like this
0 votes
Prem Chudzinski _extensi_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 12, 2016
Deleted user June 14, 2016

Looks like this is applicable on-premise JIRA instance. We are using JIRA on-demand. Is there configuration for the same ?

Prem Chudzinski _extensi_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 15, 2016

You need to check with Atlassian support team what is the default value for You.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events