Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,920
Community Members
 
Community Events
177
Community Groups

'Total' field is missing from the api response

Edited

In the jira rest API doc for getting all sprints the api given is GET /rest/agile/1.0/board/{boardId}/sprint and the response is given as,

{ "maxResults": 2, "startAt": 1, "total": 5, "isLast": false, "values": [ { "id": 37, "self": "http://www.example.com/jira/rest/agile/1.0/sprint/23", "state": "closed", "name": "sprint 1", "startDate": "2015-04-11T15:22:00.000+10:00", "endDate": "2015-04-20T01:22:00.000+10:00", "completeDate": "2015-04-20T11:04:00.000+10:00", "originBoardId": 5 }, { "id": 72, "self": "http://www.example.com/jira/rest/agile/1.0/sprint/73", "state": "future", "name": "sprint 2" } ] }

 

 

here the field 'total' is in the api response but when calling the api all the other fields except "total' is coming...

how to get the total count of sprints in a board? 

1 answer

0 votes

Sprints are specific to boards, not projects.

If you wanted to know the total sprints for a project, you'd have to get a list of all the boards first, then iterate through querying each board to get the number of sprints in that board, then total them all up.

Sorry let me correct one thing first,  I am looking to find out a way to get the total sprints in a board.

Say there is a board and it consists of 90 sprints and when I run the API,  the response will consists of maximum 50 results. I'm wondering how to get the remaining 40 sprints in that board without having the total value in the API response.

If there is total value then I could use maxResults=total value

Also I've tried  GET /rest/agile/1.0/board/{boardId}/sprint? maxResults=x where x is a static value. But whenever I tried to give x value higher than 50 it won't show the maximum value(maxResults) as x in the API response instead it shows 50.

So how could I get the total sprints in a board?

For various objects, the REST API restricts the number of results returned to help manage processing load. When this happens, you need to do your searches in batches of that number; in this case it's batches of 50.

You use the startAt parameter to set the index point of where to start each search. You start at 0 then increment it by 50 each time until all the results have been returned or the value isLast is returned as true.

Refer to the Expansion, pagination, and Ordering section of the REST API documentation to understand how to use startAt, maxResults, total and isLast together in your queries to get all the sprints from a board.

"Refer to the Expansion, pagination, and Ordering section of the REST API documentation to understand how to use startAt, maxResults, total and isLast together in your queries to get all the sprints from a board."

 

The point is there is no total returned by the API when working out the total number of sprints personally I don't want to iterate my way through an endless loop calling the next 50 and the next 50 and the next 50 which pretty much negates the 'saving resource' argument as multiple calls are way more expensive, I'd prefer to know that I have 1000 sprints and then I'd like to return the last 50 iterate round untill I get to the sprints I want, WHY ! does the total not get returned as per the documentation is the question ?

Like hemanth415 likes this

I have documented this at https://jira.atlassian.com/browse/JSWCLOUD-23039. Please feel free to add other endpoints you find with the same behavior (the total value missing).

Like hemanth415 likes this

Suggest an answer

Log in or Sign up to answer