JIRA- How to change issue status via rest?

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

This widget could not be displayed.

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!

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

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

Great to know that Bahar. :)

Anyway, could you please mark this thread as answered?

Thanks.

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

Have a pleasant day!

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!

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

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?

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.

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).

 

 

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.

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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

292 views 5 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you