is it possible to programmatically reopen an already closed issue in Jira?

I need to programmatically reopen issues that has already been closed, is this possible? I have seen some documentation on edit an issue, but "status" field is not listed amongst the things rest api support of manipulation currently.

3 answers

1 accepted

Accepted Answer
0 votes

Hi Jeff, I think this can be done with Global Transitions in Workflow designer. You can define Global transition to some status, i.e. Open(this is Destination step) and when you Closed your Issue, you will always have an workflow(on your Issue screen) option to set the status back to Open.

Global transition has own ID(visible in brackets in workflow designer), so you can via REST API post JSON like this

{
  "transition": {
    "id": "111"
  }
}

to this url "/rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields" and your Status should be updated.

In .NET you can use classes like HTTP, HTTPRequest(these are from Apex language), to send POST request to JIRA.

If you don't understand me, I can explain you this process better.

Michal

Thanks Michael, this is great info to have. I also figured out how to make it work in Soap API - basically I need to call the API like this:

issue.WorkflowTransition(Action Name) where Action Name is something I can only see by using Get on "/rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields". In my case it is actually "ReOpen Issue".

Good work! But remember SAOP and XML-RPC API will be deprecated in JIRA 6.0 . I also have SOAP API in integration project for creating Project in JIRA through API, but Atlassian want to extend REST API to cover also Project creation and others things which are now only in SOAP.

0 votes

Very true - status is not a field, it's a display telling you where an issue is in the workflow.

To re-open an issue via code, you need to do two things

1. Ensure the workflow has a transition from closed to open/reopened/whereever

2. Run the workflow transition.

Obviously the API supports this (otherwise the web UI couldn't do it), but other interfaces do as well - REST etc. You haven't said where you want to write the code, so I can't really tell you what to look for next!

Thank you Nic for the direction. I am using the .Net SDK to write my tool, and was able to edit issues as long as they are not closed.

Once the issue is closed, I did see my transaction ID as http://jira/secure/WorkflowUIDispatcher.jspa?id=66659&action=3&atl_token=A7J2-MJTC-679C-HTVE|6b6c7e43059db906407fb8570b9d23fc683ff809|lin

However, when I tried to change the status of a closed issue by calling this statement:

issue.WorkflowTransition("3");

I ended up with the following exception:

System.InvalidOperationException was unhandled
Message=Worflow action with name '3' not found.
Source=Atlassian.Jira
StackTrace:
at Atlassian.Jira.Issue.WorkflowTransition(String actionName)
at JiraInfoCollector.Form_JiraCop.dataGridView_TableView_CellMouseDown(Object sender, DataGridViewCellMouseEventArgs e) in C:\Projects\JiraTools\JiraCop\JiraCop.cs:line 165
at System.Windows.Forms.DataGridView.OnCellMouseDown(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)

<font></font>

Any idea what's the right way to call this API via C#?

<font></font>

Thanks Michal, this is very important info to have. looks like I will have to shift my coding to favor REST API first. Good thing is we have till 7.0 to complete a transition plan, not sure how long that means in Atlassian calendar...

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

120 views 6 8
View post

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you