Get id of the active sprint

andrea.giordano April 22, 2021

Hi all,
I'm implementing an application that, using the JIRA REST API, automatically creates issues: I would also like to assign them to the current active sprint. To do so, I've retrieved the customfield_XXXX code of the "Sprint" field and implemented the following alike body request:

/rest/api/3/issue
{
    "fields": {
       "project":
       {
          "key": "SP"
       },
       "summary": "Sprint issue test",
       "description": "REST APIs are great.",
       "issuetype": {
          "name": "Bug"
       },
       "customfield_XXXX": activeSprintID
	}
}



Still, I need an automatic way to retrieve the ID of the current active sprint and I'm trying to use this REST API to get it:

/rest/agile/1.0/board/{boardId}/sprint?state=active&maxResults=1

which apparently does not work and links me to a dead link.

How can I retrieve the ID of the current active sprint to embed it in the previous body request?

Thanks all,
Andrea

3 answers

3 votes
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.
April 23, 2021

Hi @andrea.giordano  -- Welcome to the Atlassian Community!

If you are not using parallel sprints, you may get the current active sprint as you would with a JQL query: sprint IN openSprints() AND sprint NOT IN futureSprints() AND sprint NOT IN closedSprints()

Pleases substitute in your project key.

/rest/greenhopper/latest/integration/teamcalendars/sprint/list?jql=project=myProjectKey%20AND%20sprint%20IN%20openSprints()%20AND%20sprint%20NOT%20IN%20futureSprints()%20AND%20sprint%20NOT%20IN%20closedSprints()


Best regards,

Bill

Dennis Lindqvist September 29, 2022

REMOVED

0 votes
Dennis Lindqvist September 29, 2022

~~~

sprint IN openSprints() AND sprint NOT IN futureSprints() AND sprint NOT IN closedSprints()

~~~

doesn't work for items that's been part of more than one sprint and is still active :/

Try using this instead

~~~

sprint IN openSprints() AND sprint NOT IN futureSprints() AND (sprint NOT IN closedSprints() OR (sprint IN openSprints() AND sprint NOT IN futureSprints()))

~~~

 

And of course, converting it to REST.

0 votes
Kevin Johnson
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 23, 2021
Hector Kurtyanek February 1, 2023

Just what I was looking for - thanks!

Suggest an answer

Log in or Sign up to answer