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 01 Answer
Reset to default 5The 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:
- Create your parent issue by using
POST /rest/api/2/issue
and save the issue key from the response. - 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.