How do I set startAt and maxResults in curl request?

Araiz Baqi July 26, 2017

I'm using curl to search for issues in JIRA

This is my command:

curl -D- -u user:pass -X GET -H "Content-Type: application/json" https://jira.example.com/rest/api/latest/search?jql=.............xmlQuery............

The problem is that i only get 50 issues. I want to set the startAt and maxResults parameters but can't seem to get it right. Can anyone help?

1 answer

2 votes
Gaston Valente
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.
July 26, 2017

Hi Araiz,

This is the way:

/rest/api/2/search?jql=[jqlQuery]&startAt=10&maxResults=3

Araiz Baqi July 26, 2017

Gaston, 

I tried that, and it says 'startAt' and 'maxResults' is not recognized as an internal or external command.

Do you have an idea what what I might be doing wrong?

The query works with:

 rest/api/latest/search?jql=projects+%3D+JIT.......

Like LABARRE Anthony likes this
Gaston Valente
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.
July 26, 2017

I'm copying the code i place in the answer and works.

try with a simple query to check for a syntax problem:

/rest/api/2/search?jql=project=XXX&startAt=3&maxResults=5

Like Siwen Yu likes this
Nada El Boustaoui July 17, 2018

@Gaston Valente hi i tried that and the problem i get is that if i set startAt=0 and maxResult=50 i get 50 issues in return but then when i change it to startAt=50 and maxResult=100 i get 100 issues. when i do this in a loop it blocks the connection at one point i guess because the data becomes too large. Do you have any idea why i can"t set the startAt to a percise value ?

Gaston Valente
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.
July 17, 2018

You need to specify startAt=50 and maxResults=50

That will bring the 50 records after the first 50

  • startAt defines the offset
  • maxResults define the returned records count after the offset

startAt=0 and maxResults=50 returns the first 50 records

startAt=50 and maxResults=50 returns the following 100 records after the first 50

you need to keep track of the returned record count in each call and adjust the startAt value

S
Contributor
July 27, 2021

@[deleted] I have implemented same approach but the results are not as i wanted.

 

startAt=0 and maxResults=50 returns the first 50 records

startAt=50 and maxResults=50 returns the following 100 records after the first 50

 

with this approach I'm getting a few similar records from both dataset... is there a way I can filter or order things to get sequential to get distinct data set every time?

Like Lyuboslav Mitsov likes this
TN
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 14, 2024

This is an old thread but hopefully this will help someone.

I tried to get the maxResults to return above 50 and they won't, so there is no reason to use this variable. If you have 20 values the call will return 20 values. Just make a loop and change the starting index. First call 0, next 50, ....

Using python here is how the url should look: f'/rest/agile/1.0/board/{epic_id}/epic?jql=%startAt={start_index}.

This way you can set the start_index=0 for the first iteration and then put your call into a loop until ["isLast"] comes back True. I recommend appending ['values'] to the original call of 50 so all the values will be in the same place at the end of the loop.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events