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,
Community moderators have prevented the ability to post new answers.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should be able to use the following JSON in your POST call:
{
"update": {
"comment": [
{
"add": {
"body": "Bug has been fixed."
}
}
]
},
"transition": {
"id": "5"
},
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Christina,
it looks like you have to update "Reason" field as well (required field).
Tom
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @tomd ,
When I use PUT API: /rest/api/2/issue/{issueId} for update issue with body below:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you try to use the following api https://docs.atlassian.com/software/jira/docs/api/REST/9.3.1/#api/2/issue-doTransition
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is this works only for api version 2?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.