David Buddrige
David Buddrige

Reputation: 73

Programmatically Closing a task in JIRA using REST API

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?

Upvotes: 1

Views: 1668

Answers (1)

tcbrazil
tcbrazil

Reputation: 1325

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.

Upvotes: 1

Related Questions