1

I am writing a program which interrogates our JIRA system using REST calls for tasks that have been marked as being the responsibility of a different department.

My program then proceeds to create jobs on the job-tracking system owned by that other department, and updates our JIRA task with the new Job id on the other department's system.

What I now want to do is to update the JIRA task on our own system as being Closed. However, while have been able to use the rest calls (along with a bit of json) to extract fields, and update both standard and custom fields in JIRA, one field I cannot seem to update is [either] the "status" field or the "resolution" field.

The REST http string I'm using to attempt to do this (in C#) the following is:

"http:[my-jira-server]/rest/api/2/issue/" + task.key + "/editmeta";

and then with the following json string:

        string theJson =
                  "{" +
                  "    \"fields\": " +
                  "    {" +    
                  "       \"resolution\": \"Done\"" +
                  "    }" +
                  "}";

I've also tried

        string theJson =
                  "{" +
                  "    \"fields\": " +
                  "    {" +
                  "        \"status\": Done "
                  "    }" +
                  "}";

and also:

        string theJson =
                  "{" +
                  "    \"fields\": " +
                  "    {" +
                  "        \"status\": \"Done\" "
                  "    }" +
                  "}";

But in each case, I get a WebException error:

"The remote server returned an error: (405) Method Not Allowed"

Is it possible to close off a JIRA job using the REST API?

Nuwan
  • 1,226
  • 1
  • 14
  • 38
  • I have also tried running a straight http GET against the following url: http://[my-jira-server]/rest/api/2/issue/" + jiraTaskId + "/editmeta" – David Buddrige Feb 12 '15 at 00:03
  • I have also tried running a straight http GET against the following url: http://[my-jira-server]/rest/api/2/issue/" + jiraTaskId + "/editmeta" which produced a list of editable fields (which apparently are the editable ones and don't include the status field or the resolution field) - but is it really the case that you cannot edit the status field (or set it in some way programmatically) ? – David Buddrige Feb 12 '15 at 00:09
  • I figured out the solution: First of all, for transferring to open/closed/done, etc, I needed to use the transition rest call (as a POST), which is (in C#): "http://[my-jira-server]/rest/api/2/issue/" + task.key + "/transitions"; secondly, the json to get it to transition to "done" was : string theJson = "{" + " \"transition\": " + " {" + " \"id\": \"21\" " + " }" + "}"; – David Buddrige Feb 12 '15 at 06:05
  • To find the available transitions, I sent the following GET call (from the C#) string url = "http://[my-jira-server]/rest/api/2/issue/" + jiraTaskId + "/transitions?expand=transitions.fields"; – David Buddrige Feb 12 '15 at 06:05
  • if you can put the complete answer with the code it would be really helpful to others..:) – Nuwan Aug 10 '15 at 05:41

1 Answers1

1

You have the same problem this guy has (Updating a jira issue with the rest api. NOT soap), editmeta is not to edit, just to OBTAIN meta information (I guess Atlassian picked a not-so-good name). You must use issue instead.

tcbrazil
  • 1,315
  • 12
  • 25