How to change the issue status by REST API in JIRA?

Samuel Donadelli July 23, 2018

Hi guys,

 

I am using a curl PUT command to update JIRA issue status, it is returning the HTML 204 response but no status is being updated. The only thing being updated is a comment into the issue "test test". The transition id 101 is "In progress".

What am I doing wrong?

See code below:  

 

curl -v -D- -u username:password -X PUT --data \'{"update": {"comment": [{"add": {"body": "test test"}}]}, "transition": {"id":"101"}}\' -H "Accept:application/json" -H "Content-Type:application/json" "https://tests.atlassian.net/rest/api/2/issue/TES-3"

 

cheers, 

 

 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

6 votes
Answer accepted
tomd
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 23, 2018

Hello Samuel,

To update an issue status you need to call the transition action with POST:

curl -u username:password -X POST --data '{"transition":{"id":"11"}}' -H "Content-Type: application/json" http://jira/rest/api/2/issue/TEST-1/transitions

Reference: 
https://docs.atlassian.com/software/jira/docs/api/REST/7.11.0/#api/2/issue-doTransition

I hope that helps,

Tom

Samuel Donadelli July 24, 2018

@tomd thanks very much for your solution it works properly. 

 

I wonder how we can keep the comment there to work. 

 

Would you know if it is possible to use POST with a comment (like in same curl command)?

Or should I pass 2 curl commands one for POST (transition) one for PUT (comment)? 

 

Cheers, Sam 

tomd
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2018

You should be able to use the following JSON in your POST call:

{
"update": {
"comment": [
{
"add": {
"body": "Bug has been fixed."
}
}
]
},
"transition": {
"id": "5"
},
}
Samuel Donadelli July 24, 2018

@tomd 

Hello, I tried this piece of code you suggested me. However, I wasn't able to add the comment. 

The only update was on the transition. 

I made other test by using two curl commands, one POST (transition) and one PUT (comment) and it worked properly.

I wonder if update:comment:add works only with PUT, instead of POST. 

Thanks, Sam 

tomd
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2018

Sam,

I've just checked it for you, it works in my test environment (Jira 7.6.6):

curl -u username:password -X POST --data '{ "update": { "comment": [ { "add": { "body": "Bug has been fixed." } } ] }, "transition": { "id": "2" } }' -H "Content-Type: application/json" http://jira/rest/api/2/issue/TEST-1/transitions

I would recommend you to install REST API Browser add-on and try:

Tom

Like Evgen Kyselgov likes this
李冲 August 6, 2018

@Tomasz Dudzisz Hi, I am trying to use your example to update JIRA ticket.  But I got below error response. The original ticket is a product level bug, I am not sure where and how to fix it. Can you please give me some suggestion? Thanks. 

"error": {
 "errorMessages": [],
  "errors": {
   "customfield_28700": "Reason for the Bug is required for Production Bugs"
  }
}

tomd
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2018

Hello Christina,

it looks like you have to update "Reason" field as well (required field).

Tom

Phan Kieu Hung October 17, 2022

Hi @tomd ,

When I use PUT API: /rest/api/2/issue/{issueId} for update issue with body below:

{
    "fields": {
        "summary""This is a shorthand for a set operation on the summary field",
        "timetracking": {
            "originalEstimate""80"
        }
    },
    "transition": {
        "id""51"
    }
}
In spite of API response 204 (Update success). But "transition" do not update.
The id transition I collect from API: /rest/api/2/issue/{issueId}/transitions.
Look like "transition" can not editable.
I check fields editable via: /rest/api/2/issue/{issueId}/editmeta

So we must call 2 API for update issue.
1. Update data normal. (PUT:  /rest/api/2/issue/{issueId} )
2. Update status (transition) (POST: /rest/api/2/issue/{issueId}/transitions )
Do you have discuss about it?
Thanks,
hungpk
Like Mateus Martins likes this
Mohamed Adel
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.
October 29, 2022
Hassan Rachid November 22, 2022

Hi @Mohamed Adel 

 

That endpoint works for me, however, the edit issue documentation does state that you can transition statuses while editing an issue. I already have an existing endpoint that calls that endpoint, so I tried to add status transitions to the request body. The API response is 204, but the issue status never changes. Is it possible to transition status using the edit endpoint? Or must we use the one you linked?

Like # people like this
Nicketa February 24, 2023

Comment or any field update only works when there is a screen on transition, which have fields to be updated.

0 votes
vinay November 16, 2021

is this works only for api version 2?