Change issue state from ready to inProgress with REST API

ofer hai March 30, 2015

I haven't found a way of doing that works for me, this method return an error : 500 

url ... /jira/rest/api/2/issue/JC-11/transitions?expand=transitions.fields

{
    "update": {
        "comment": [
            {
                "add": {
                    "body": "Comment added when resolving issue"
                }
            }
        ]
    },
    "transition": {
        "id": "5"
    }
}
Please advise.
Ofer.

7 answers

1 accepted

0 votes
Answer accepted
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 31, 2015

Hello Ofer,

Could you please add the JSON to a file (i.e.: parameters.json)

'{ "update": { "comment": [{"add": {"body": "Bug has been fixed."}}] } , "fields": {"assignee": {"name": "osh"}, "resolution" : {"name": "Fixed"} },"transition": {"id": "21"} }'

Then call the cURL  as per following:

curl -D- -u [USERNAME] -p -H "Content-Type: application/json" -X POST --data "@parameters.json" https://xxxx.atlassian.net/rest/api/2/issue/SUMA-6/transitions

Could you attempt on running the cURL provided in this thread in different boxes, please?

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

0 votes
ofer hai March 31, 2015

Hi Rafael,

I finally got it to work smile it seem like the fields asignee and resolution wasn't defined, so i used only transition and it works!

{ "transition": {"id": "21"} }

Thanks for your help.

Ofer.


0 votes
ofer hai March 31, 2015

I wasn't ware cUrl returns anything else but an Error.

I'm using my own c# program to call rest api, I've followed your instruction and set transition id according to my project.

Here is my cUrl command:

curl -D- -u api-admin -p -H "Content-Type: application/json" -X POST -d

 '{ "update": { "comment": [{"add": {"body": "Bug has been fixed."}}] } , "fields": {"assignee": {"name": "osh"}, "resolution" : {"name": "Fixed"} },"transition": {"id": "21"} }' https://xxxx.atlassian.net]/rest/api/2/issue/SUMA-6/transitions

cUrl response:

Enter host password for user 'api-admin':
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] bad range specification in column 2
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 20
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 4
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 6
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 3
curl: (3) [globbing] unmatched close brace/bracket in column 33

 

It make no sens, all braces are in place.

 

Ofer.

0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 31, 2015

Hello Ofer,

Thank you for your question.

You can verify the transition ids under "JIRA administration >> Issues >> Workflows" by clicking on "Operations >> View" to the selected workflow. In my example below, I have selected: "The default JIRA workflow.

Screen Shot 2015-03-31 at 10.02.55 AM.png

By running the cURL commands that have been mentioned in this thread, the response will tell you what is wrong and what needs to be done. It would be easier if you could provide the command you are running and the response given so we could verify the issue you are facing and provide you with a better response.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

 

0 votes
ofer hai March 30, 2015

Hi Rafael and Jaime,

Thank you for your response, I’m afraid it’s still not working for me … Here is my post data:

{

                "update":

                    {

                        {"comment": [{"add": {"body": "Bug has been fixed."}}]},

                        "fields": {

                                  "assignee": {"name": "osh"},

                                  "resolution": {"name": "Fixed"},

                                  "transition": {"id": "500"} }

                    }

            }

Posted to this url: https://xxxxx.atlassian.net/rest/api/2/issue/MAIT-150/transitions

 

I also wonder about transitions state codes:

 

What is the code for:

Ready -> InProgress transition

InProgress -> Done transition 

Cheers,

Ofer

0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2015

Hello Ofer,

Thank you for your question.

As @Jaime Silveira has mentioned there is no need to expand in the REST API call. Instead, you could be running the following command as mentioned earlier:

# [USERNAME], i.e.: admin
# [ASSIGNEE], i.e.: someone
# [JIRA-BASE-URL], i.e.: http://my.jira.domain
# [ISSUE-KEY], i.e.: ABC-1
curl -D- -u [USERNAME] -p -H "Content-Type: application/json" -X POST -d '{"update": {"comment": [{"add": {"body": "Bug has been fixed."}}]},"fields": {"assignee": {"name": "[ASSIGNEE]"},"resolution": {"name": "Fixed"}},"transition": {"id": "500"}}' [JIRA-BASE-URL]/rest/api/2/issue/[ISSUE-KEY]/transitions
 
# in the command above, you will be prompted to type in user's password
# alternatively, you could run
# [USERNAME], i.e.: admin
# [PASSWORD], i.e.: mypassword
curl -D- -u [USERNAME]:[PASSWORD]

 

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

0 votes
Jaime S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2015

Hi, Ofer.

Since you're using Cloud, when you replaced the 'localhost:8080', did you remove the '/jira'? This is not included in Cloud instances.

It would be something like:

instance.atlassian.net/rest/api/2/issue/JC-11/transitions

 

Also, this is a POST, so I don't think you should use the expand.

If these changes don't work, could you send us the full command you're using?

 

I hope it was helpful.

Kind regards,
Jaime Kirch da Silveira
Atlassian Cloud Support

Suggest an answer

Log in or Sign up to answer