javascript - JIRA API create issue and subtask in a single api call - Stack Overflow

I am working on creating a script where I want to create a jira ticket along with several sub tasks. I

I am working on creating a script where I want to create a jira ticket along with several sub tasks. I am able to figure out creation of issue as well as sub tasks in different API calls with the following payload:

{
    "fields": {
       "project":
       { 
          "key": "TEST"
       },
       "summary": "TEST summary",
       "description": "TEST Description",
       "issuetype": {
          "name": "Bug"
       }
   }
}

Create a sub-task and attach it to the issue from above API call:

{
    "fields":
    {
        "project":
        {
            "key": "TEST"
        },
        "parent":
        {
            "key": "TEST-1"
        },
        "summary": "Sub-task of TEST-1",
        "description": "TEST-1 desc",
        "issuetype":
        {
            "id": "5"
        }
    }
}

However, I want to do both in a single API call. Is it something that can be done ?

I am working on creating a script where I want to create a jira ticket along with several sub tasks. I am able to figure out creation of issue as well as sub tasks in different API calls with the following payload:

{
    "fields": {
       "project":
       { 
          "key": "TEST"
       },
       "summary": "TEST summary",
       "description": "TEST Description",
       "issuetype": {
          "name": "Bug"
       }
   }
}

Create a sub-task and attach it to the issue from above API call:

{
    "fields":
    {
        "project":
        {
            "key": "TEST"
        },
        "parent":
        {
            "key": "TEST-1"
        },
        "summary": "Sub-task of TEST-1",
        "description": "TEST-1 desc",
        "issuetype":
        {
            "id": "5"
        }
    }
}

However, I want to do both in a single API call. Is it something that can be done ?

Share Improve this question asked Jan 29, 2019 at 23:30 CodeMonkeyCodeMonkey 2,2959 gold badges50 silver badges97 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 5

The Jira REST API does not offer such kind of operation. It does offer a bulk endpoint for creating multiple issues, but you can't define something like "issue one is the parent issue of issue two which is declared further down in the JSON file".

You have to use two different API calls:

  1. Create your parent issue by using POST /rest/api/2/issue and save the issue key from the response.
  2. Create the sub tasks with a bulk operation using POST /rest/api/2/issue/bulk.

The links are referring to the REST API docs for Jira Server, but the same is possible with the REST API in Jira Cloud. Only the authentication method is different.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744848473a4596985.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信