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

Deleted user April 4, 2013

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

0 votes
Answer accepted
Michal Husar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 8, 2013

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

Deleted user April 8, 2013

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".

Michal Husar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 10, 2013

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
Deleted user April 15, 2013

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...

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 4, 2013

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!

Deleted user April 4, 2013

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>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events