Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to create a subtask with Json REST api

Herbert Mahalek November 21, 2011

I'm looking for a example to create a sub-taks with Json using the REST api in Jira. Is there a example how the json data should look like?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Wojciech Seliga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2011

Hey, in JIRA prior 5.0 you cannot create issues (which includes sub-tasks) via REST API.

In 5.0 you can create sub-task via REST using the same URL as for normal issue.

Just provide parent field with id or key and then REST plugin will create a sub-task rather than an top-level issue.

E.g. POSTing the following JSON to /rest/api/2/issue should create a sub-task

{
   "fields":{
      "parent":{
         "id":"10010"
      },
      "project":{
         "id":"10000"
      },
      "summary":"a sub-task of my first issue",
      "issuetype":{
         "id":"5"
      },
      "assignee":{
         "name":"fry"
      },
      "reporter":{
         "name":"farnsworth"
      },
      "priority":{
         "id":"1"
      },
      "labels":[
         "abc",
         "def"
      ],
      "timetracking":{
         "originalEstimate":"120",
         "remainingEstimate":null
      },
      "security":{
         "id":"10000"
      },
      "versions":[
         {
            "id":"10000"
         }
      ],
      "environment":"environment",
      "description":"description",
      "duedate":"2011-03-11",
      "fixVersions":[
         {
            "id":"10001"
         }
      ],
      "components":[
         {
            "id":"10000"
         }
      ]
   },
   "transition":null
}

provided that issue with id 10010 already exists. and all other params are OK.

JIRA 5.0 RC1 released a few days ago should support it.

Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2011
Thank you for pointing this out. i didn't find the "parent" parameter seems to be missing in the documentation
Chidambaram C July 30, 2013

Is it possible to update the subtask? Is there any reference for JSON representation?

Ahmed Almukhtar October 3, 2017

put     https://url/rest/api/2/issue/(subtaskId)

 

{
"fields": {
"parent": {
"Key": "A Subtask created "
},
"summary": "A Subtask created by project key through rest api "
}
}

 

This will help you to update the summary of the subtask

0 votes
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2011
Only JIra 5 allows creating issues using the REST Api. Please check http://docs.atlassian.com/jira/REST/5.0-rc1/#id2490687 Also there seems to be no way to create subtasks directly in this Api. maybe it works to create the two issues (parent,child) first and then link them using a link of type jira_subtask_link. linking seems to be possible in Jira 5 REST Api
TAGS
AUG Leaders

Atlassian Community Events