How do I get issues more than 1000 with a single REST request?

I'm developing a desktop app using JIRA Cloud API. I want to get all issues but it's limited to 1000 max per request.

I tried to use while function with the statement; if the total number of issues if bigger than retrieved issues, then repeat the REST request. See the code below.

But unfortunately, this did not work. In fact, it crashed.

client.get(`${host}/rest/api/2/search?jql=assignee=currentuser()&startAt=0&maxResults=1000`, authParams, function(data, response){

issues = data.issues;
total = data.total;

while(issues.length < total){

client.get(`${host}/rest/api/2/search?jql=assignee=currentuser()&startAt=${issues.length + 1}&maxResults=1000`, authParams, function(data, response){
issues = issues.concat(data.issues);
});
}

}); 

Can anyone help? Thanks!

1 answer

0 votes
Warren Levy Community Champion Aug 25, 2017

Hi Bhakti

It looks like you're on the right track, but you need a minor change :

Your first call gets the first 1000 issues (0 - 999), which should work

Within the while, I think issues.length is the total number of available issues, not the number of issues returned from the first call. Let's say you have 1600 issues, you're telling it to start at 1601 (instead of 1000), which causes the crash

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,739 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot