Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,725
Community Members
 
Community Events
176
Community Groups

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

Edited

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

5 votes
Answer accepted
tomd Atlassian Team Jul 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

@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 Jul 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"
},
}

@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 Jul 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

@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 Aug 06, 2018

Hello Christina,

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

Tom

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

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 Mateus Martins likes this

is this works only for api version 2?

Suggest an answer

Log in or Sign up to answer