0
votes

I am trying to write a method that will allow users to close a JIRA issue using json. Here is the url I am using:

../jira/rest/api/latest/issue/MyProj-524/transitions

Here is my json string:

 { "update" : {"comment": [{"add": {"body":"Fixed"}}]}, "fields" : { "resolution" : {"id":"10000","name":"Done" }}, transition": {"id": "6"}}

I get a 400 exception (Bad Request) and status of ProtocolError. According to the documentation 400 will be returned if there is no transition specified.

Also when I query the JIRA server from my browser with
..:8090/jira/rest/api/latest/issue/MyProj-524/transitions I get the following:

 {"expand":"transitions","transitions":[{"id":"5","name":"Resolve Issue","to":{"self":"/jira/rest/api/2/status/5","description":"A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.","iconUrl":"..8090/jira/images/icons/statuses/resolved.png","name":"Resolved","id":"5","statusCategory":{"self":"...8090/jira/rest/api/2/statuscategory/3","id":3,"key":"done","colorName":"green","name":"Done"}}},{"id":"2","name":"Close Issue","to":{"self":".:8090/jira/rest/api/2/status/6","description":"The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.","iconUrl":"..8090/jira/images/icons/statuses/closed.png","name":"Closed","id":"6","statusCategory":{"self":"8090/jira/rest/api/2/statuscategory/3","id":3,"key":"done","colorName":"green","name":"Done"}}}]}

So it appears there are available transitions. We are using the "Classic Default Workflow" that contains: Open, Resolved, Closed, Reopened, and In Progress. The current status of the ticket is: Open.

1

1 Answers

0
votes

Are you sure you're using the correct transitions id? Did you check against

.../jira/rest/api/latest/issue/MyProj-524/transitions?expand=transition.fields

Your id should match the transition you want to convert to. In my case (using the standard transitions that come with the Jira cloud, my ID is 31 (for "Done")

You might also want to confirm that your workflow allows for taking an issue from Open to Closed. You can view this as a diagram from Admin > Issues > Workflows > Assigned schemes > View as a diagram

There are some more suggestions here:

https://answers.atlassian.com/questions/86247/how-can-i-close-an-issue-via-a-rest-api-call