Child pages
  • How to add and remove issue to/from Sprint via REST API
Skip to end of metadata
Go to start of metadata

This article will show you how to add or remove issue to an active sprint, which already has a valid Sprint ID.

  • To add issue to sprint

Method: PUT

REST API: sprint/{sprintId}/issues/add

Example URL: http://jira:8080/rest/greenhopper/1.0/sprint/1/issues/add

Example JSON data: {"issueKeys":["DEMO-1"]}

  • To remove issue from sprint

Method (for JIRA Agile 6.2 and later): PUT

Method (for earlier version of GreenHopper, example GH 6.0.1): DELETE

REST API: sprint/{sprintId}/issues/remove

Example URL: http://jira:8080/rest/JIRA Agile/1.0/sprint/1/issues/remove

Example JSON data: {"issueKeys":["DEMO-1"]}

The following is the complete example using cURL:

curl -D- -u admin:admin -X PUT -d '{"issueKeys":["DEMO-1"]}' -H "Content-Type: application/json" http://jira:8080/rest/greenhopper/1.0/sprint/1/issues/add

To find more other JIRA Agile REST API, you can install Developer Toolbox and see the page on REST API. It will show the REST API that can be used in JIRA Agile as well by clicking on the dropdown besides the topic name.

10 Comments

  1. Hello,

    http://jira:8080/rest/greenhopper/1.0/sprint/1/issues/add  end point is not working with JIRA Agile 6.3.1. Can somebody please respond? 

    Thanks!

  2. Has nobody found out how to do this in Agile? Or is it really not possible any more? I want Greenhopper back. (sad)

  3. Is there any resolution to this problem?  The server response is:

    {"message":"null for uri: https://jira:8080/rest/greenhopper/1.0/sprint/1/issues/add","status-code":404}

  4. I could add issue to Sprint following way.

    Method: PUT
    REST API: /sprint/rank
    Example URL: http://jira:8080/rest/greenhopper/1.0/sprint/rank
    Example JSON data: {"idOrKeys":["DEMO-1"],"customFieldId":10002,"sprintId":40,"addToBacklog":false}

    10002 = ID of Rank CustomField.

    Hope this helps!

    Atlassian should update the content this page to reflect updated endpoints.

  5. Hi Sunita

    Can you please help me on how to remove an issue from a sprint in JIRA agile?

    arsh

    1. Hi Arsh,

      You can try the following to remove an issue from a sprint.

      Method: PUT
      REST API: /sprint/rank
      Example URL: http://localhost:8080/rest/greenhopper/1.0/sprint/rank
      Example JSON: {"idOrKeys":["SSP-2"],"customFieldId":10004,"sprintId":null,"addToBacklog":true,"idOrKeyBefore":"SSP-3"}

      You would require to add the idOrKeyBefore when the backlog or sprint is not empty and would like to rank it to an issue before that specified issukey.

      1. Why JIRA Agile is not providing this solution in its API ?

        https://jira.atlassian.com/plugins/servlet/restbrowser#/resource/greenhopper-1-0-sprint-sprintid/DELETE

        There is no body also. How can one create body from only REST query ?

      2. Also this solution will update "Rank" history also which is not desirable. What if I don't want to update rank field and just want to add/remove issue in Sprint ?

         

        Is there any way to just add/remove sprint-issue without having history of "Rank" field ?

  6. I know this thread is old, but I stumbled upon it to try and find the answer.

    Find what the custom field id of the sprint field is and pass the sprint id with it in the fields object when creating or updating an issue:

    {"fields" : {

        "customfield_10803" : 275 

        }

    }

  7. +1 to Adrian Nichols. The Standard REST/json API works as Adrian describes just setting the customfields. I found out the Epic custom field for our installation by dumping a JIRA which I knew had an epic link defined on it. So I looked for all the customfields with what looked like a JIRA number on them and checked those (there were only a couple) to see which had the epic key (you don't see the name) I was looking for. Hence I could figure out which custom field to use. For the "team" field it was a bit easier as the customfield held the text name of the team. I guess the same technique will work for most custom fields. Obviously if your JIRA installation is updated, moved or re-installed then the custom field numbers may change so bear that in mind....

    By the way, greenhopper did work to add the Epic link to the JIRA task/story as described at the top of the article - see my example below (I only tested it with curl but I'm sure I could have got this working with python too). Where XXX-12345 is the task and YYY-98765 the epic key.


    curl --verbose --insecure --user myuser:mypassword -d '{"ignoreEpics":true,"issueKeys":["XXX-12345"]}' -X PUT -H "Conte
    nt-Type: application/json" https://our.jira.url/rest/greenhopper/1.0/epics/YYY-98765/add