Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JQL using startAt does not work

Lily Tran July 29, 2020

Hello, I am trying to use the field startAt  as the start of the Jira issueID to start the search of Jira issues in a Jira project.   I am using the curl command to do a Jira Rest API to do a search query of the Jira Project, and would like to get the first 5 Jira IssueIDs. Below is the curl command that I am using:

/usr/bin/curl -s -u 'yyyyyyy:xxxxxxx' -X GET "https://jira.corp.adobe.com/rest/api/2/search?jql=project=DCMAF&fields=key,id,attachment&startAt=0&maxResults=5"

this query command outputs the last 5 Jira issues: Jira IssueID 128, 127, 126, 125, and 124 , but I am expecting Jira Issues: 1, 2, 3, 4, and 5 as the output.  It looks like Jira is not honoring the usage of startAt field.  Can someone help me to see if I am using the startAt correctly?

1 answer

1 accepted

1 vote
Answer accepted
Bill Sheboy
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 29, 2020

Hi @Lily Tran 

You appear to be using startAt correctly, as it is the zero-based offset (index of the first record to return).

I wonder if something earlier in the URL is parsing incorrectly and so startAt is ignored.  Maybe try removing the fields and maxResults to diagnose this piece by piece.

 

Best regards,

Bill

Lily Tran July 29, 2020

Bill;

Thank you.  I will try out your suggestion to see if I can get it to work.

Lily Tran July 29, 2020

I tried to move the startAt and maxResults before the fields:

/usr/bin/curl -s -u 'xxxx:YYYYYY' -X GET "https://jira.corp.adobe.com/rest/api/2/search?jql=project=DCMAF&startAt=5&maxResults=3&fields=key,id,attachment"

and now my search output:

DCMFA-123, DCMFA-122, and DCMFA-121 where the last Jira Issue is DCMFA-128, from the output, it looks like the jql is doing a search backward -5 off from the last Jira IssueID.  The reason I need to startAt to work correctly so that when my script run on a cron job, I want the next build to start off where the last build left off.  This way each time it run, it only process the new Jira Issues.

Any help would greatly be appreciated.

Bill Sheboy
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 29, 2020

How about putting and ORDER BY clause on your JQL?  That will enforce the order of the pulled data and make interpreting the output more predictable as you try to understand what is happening with startAt.

Lily Tran July 29, 2020

Bill;
Thanks, that did the trick by adding order by in my jql search.  Below is update command line that work:

/usr/bin/curl -s -u 'xxxx:YYYYYY' -X GET "https://jira.corp.adobe.com/rest/api/2/search?jql=project+order+by+issue=DCMAF&startAt=5&maxResults=3&fields=key,id,attachment"

Like Bill Sheboy likes this
Bill Sheboy
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 30, 2020

I am glad that worked for you.  Would you please mark this question as answered so others can find the solution more quickly?  Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events