最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论