JIRA- How to change issue status via rest?

Bahar Çağlar November 18, 2012

Hi,

I am trying to change the status of an issue via JIRA rest.

curl -D- -X PUT -H "Authorization: Basic YWRtaW46SDF0MXQ=" --data "{\"fields\":{\"summary\":\"AAAAAA\"}, \"transitions\":{\"id\": \"4\"}}" -H "Content-Type: application/json" "http://localhost:8080/rest/api/2/issue/TG-18"

Here is the data :

"{\"fields\":{\"summary\":\"AAAAAA\"}, \"transitions\":{\"id\": \"4\"}}

And the responce is 204. But the status doesnt change :( There is no error.  How can I make it work?

Thanks in advance

4 answers

1 accepted

12 votes
Answer accepted
Faisal
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.
November 18, 2012

Hi Bahar,

I did a quick test on this, and I believe that you may change an issue status by running the following cURL command:
curl -D- -u admin:admin -X POST --data @/Users/BaBs/Desktop/test.json -H "Content-Type: application/json" http://localhost:8080/jira/rest/api/2/issue/JC-11/transitions?expand=transitions.fields

Basically, you could try to run the same command by switching the user credentials, the location of the JSON data and also the hostname and I hope that it will help. For your reference, the content of the JSON file is pasted below:

{
    "update": {
        "comment": [
            {
                "add": {
                    "body": "Comment added when resolving issue"
                }
            }
        ]
    },
    "transition": {
        "id": "5"
    }
}

In my local instance, the transition with the ID 5 will resolve an issue.

I hope the above info helps!

Faisal
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.
November 18, 2012

For your reference Bahar, you may check the following REST API documentation for more info on transitioning an issue via REST:
http://docs.atlassian.com/jira/REST/latest/#id251679

Like # people like this
Bahar Çağlar November 19, 2012

Thank you Ahmad, I did what you tell, and it worked :)

Faisal
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.
November 19, 2012

Great to know that Bahar. :)

Anyway, could you please mark this thread as answered?

Thanks.

Faisal
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.
June 13, 2013

Thanks Bahar, glad to know that the info provided helps!

Have a pleasant day!

SergeZ September 16, 2013

Can you please provide a complete URL string with all necessary parameters in order to change its status considering we have an issue here : https://192.168.24.15/rest/api/2/issue/BSSS-3851.

P.S.: I would like to know what to type in a browser's address string in order to get an issue's status updated!

Thank you very much!

Chris Goldsmith September 3, 2014

As you're sending the POST request to /rest/api/2/issue/{issueIdOrKey}/transitions then the included update for the comment is not performed, it seems you need to make an additional PUT request to /rest/api/2/issue/{issueIdOrKey} for that part

edenjane October 15, 2015

Good day! I tried to use the code above and was able to successfully change the issue. However, the assignee field was also automatically assigned to me. Is there a way to retain the assignee and change the status only?

Kumar Gaurav December 22, 2016

While changing the transitions, how to update themandatory fields.

EX:- to assign an issue to QA, we need to give the Tester name along with the request file. But I am unable to do the same. Normal transitioning is happening but not while some mandatory field is also required..

please help.

Kumar Gaurav December 22, 2016

Hierarchy for the field to be updated:

 

issue:

            field:

                    custom_field( "QA Tester(s)" appears on the JIRA UI )

I need to update the name of the QA Tester(s).

 

 

Al Genzlinger March 1, 2018

I am able to successfully update an issue with the following code:

bz_answer = 'customfield_11801'
jiraput={'update' : {'summary' : [ { 'set' : summary } ]
,bz_answer : [ { 'set' : {answermode : answer } } ]
,'comment': [ { 'add' : { 'body' : comment2jira } } ]
}
}
cmd = '/rest/api/2/issue/' + issuenumber + '?notifyUsers=false'
uri = jira_server + cmd
p = requests.put(uri, json=jiraput, auth=(user, password) , verify=False )


The following command works fine for a transition:

jira.transition_issue(issuenumber, '121', fields= { bz_answer : {'value' : answer} } )


However, I get a 405 return code when attempting to update for a transition with the put method:

bz_answer = 'customfield_11801'
jiraput={'update' : { 'comment' : [ { 'add' : { 'body' : comment2jira } } ]
# ,bz_answer : [ { 'set' : {'value' : answer } } ]
},
'fields' : { bz_answer : {'value' : answer }
# bz_answer : [ { 'set' : {'value' : answer } } ]
},
'transition' : {'id' : '121'}
}
cmd = '/rest/api/2/issue/' + issuenumber + '/transitions?expand=transitions.fields'
uri = jira_server + cmd
p = requests.put(uri, json=jiraput, auth=(user, password) , verify=False )

I tried to include the custom field update within the 'update' section, or the 'fields' section and it does not make a difference.
I also tried using the set method in the 'fields' section. All of these attempts result in 405 error.


The 405 return code does not provide any error text so I have no idea what is wrong.

Al Genzlinger March 1, 2018

nevermind...   A peer reviewed and found I needed the post method rather than put method.

5 votes
paul grant June 13, 2013

Find out ID's of Transitions:

<JIRA_URL>:<JIRA_PORT>/rest/api/latest/issue/<JIRA_ISSUE>/transitions?expand=transitions.fields

Update Issue Status via:

curl -D- -u <USER>:<PASS> -X POST --data '{"transition":{"id":"<TRANSITION_ID>"}}' -H "Content-Type: application/json" <JIRA_URL>:<JIRA_PORT>/rest/api/latest/issue/<JIRA_ISSUE>/transitions?expand=transitions.fields

or:

curl -D- -u <USER>:<PASS> -X POST --data @file_name.json -H "Content-Type: application/json" <JIRA_URL>:<JIRA_PORT>/rest/api/latest/issue/<JIRA_ISSUE>/transitions?expand=transitions.fields

4 votes
churchmf September 28, 2016

I would recommend removing your Authorization header in this example as it contains your username and password in base64 encoding.

0 votes
Fabian Rohrka June 29, 2017

Hi,

I'm trying to update assignee and change state with the following code.

{
  "transition": {
    "id": "11"
  },
  "update":{
    "assignee":[{"set":{"name":"username"}}]
  }
}

I'm using PUT on

/rest/api/2/issue/ISSUEID

Just assignee changed but not the issue state.

Like # people like this

Suggest an answer

Log in or Sign up to answer