简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM