Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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, 

 

 

1 answer

1 accepted

2 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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you