I am able to loop through them all if I set the maxResult=1, all other behaves strange.
The startAt is returning a strange value and all subsequent queries are strange?
Hello @zaphnet & @Mohamed Benziane ,
You got it right and this is definitely a bug, and we were able to identify that it was introduced at version 7.13 and later. We are tracking the issue in the following bug report:
Currently, there is a comment on the request noting a partial workaround to this behavior that I copied below, that requires a bit of logic and some scripting to achieve, but hope this helps:
This needs to be fixed, but I have a workaround. The key is understanding the bug:
- startAt as returned in JSON is correctly referencing the start index (so startAt=50 gives you records 50-99 when maxResults is set to 50)/
- startAt as passed in the queryStringis beinginterpreted as a page number. Even worse, pages 0 and 1 are treated as equivalent. That is:
- /rest/api/latest/customFields?startAt=0&maxResults=50 returns records 0-49.
- /rest/api/latest/customFields?startAt=1&maxResults=50 also returns records 0-49.
- /rest/api/latest/customFields?startAt=2&maxResults=50 returns records 50-99.
Once you know that, you can write some hokey code. Remember that the startAt values you get back are record numbers!
This is a PowerShell snippet:
# Assume we're in the part where we try to build the request uri for the next page. # $temp contains the result of the last GET, including the values, isLast, startAt, and maxResults. # $uri is the uri of the prior request. if ($temp.isLast -eq $false){ $uriBuilder = [UriBuilder]$uri # See https://jira.atlassian.com/browse/JRASERVER-71303. # Bug: startAt is really Page number, and 0 and 1 are equivalent. # Jira has just passed us a record index. $startAt = $temp.startAt # what freakin' page do I need??? if ($startAt -eq 0) { # skip page 1 as it's equivalent to page 0 >:( $startAt = 2 } else { # convert the record index we were given into a page number $startAt = ($startAt / $temp.maxResults) + 2 } $uriBuilder.Query = "?maxResults=$($temp.maxResults)&startAt=$startAt" $uri = $uriBuilder.Uri } else { # set the uri to null to signal the enclosing loop to stop looping $uri = $null }
Also, I already added this thread to the list to help with visibility into affected users but please make sure to add a vote or a comment to the bug report as it helps us track affected end-users for prioritization efforts as covered in the Atlassian Bug Fixing Policy
Regards,
Earl
Hi,
I have the same thing on my server instance. I think is a bug. It seems to be a miscalculation somewhere, because when you multiply startAT by maxResults then you retrieve you startAT you get the number displayed on the json as the startAt value.
ex: /rest/api/2/customFields?startAt=10&maxResults=2 will return (2x10 = 20 -2 = 18)
18 will be the number displayed in my browser as the startAt value and 2 as the maxResults.
The same happened with your test = 20x20 = 400 - 20 =380 startAt value.
I will escalate your question to the Atlassian Team to see what they think about it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.