Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create subtasks with jira-python ?

maxandersen April 16, 2013

How does one create subtasks with the jira-python library ?

2 answers

1 accepted

2 votes
Answer accepted
maxandersen April 16, 2013

The trick is that parent id is not the issue id, but the issue key and subtype has to be 'Sub-task'

For example:

rootnn_dict = {
    'project' : { 'key': 'JBIDE' },
    'summary' : 'Test auto created issue',
    'description' : 'Ignore this. will be deleted shortly',
    'issuetype' : { 'name' : 'Task' },
    }

rootnn = jira.create_issue(fields=rootnn_dict)

print("created " + rootnn.key)

rootnn_dict = {
    'project' : { 'key': 'JBIDE' },
    'summary' : 'Test child auto created issue',
    'description' : 'Ignore this child. will be deleted shortly',
    'issuetype' : { 'name' : 'Sub-task' },
    'parent' : { 'id' : rootnn.key},
    }

child = jira.create_issue(fields=rootnn_dict)

print("created child: " + child.key)

G V Shabareesh October 10, 2018

Still i am getting error with include all of these... the error is that the issue type and id is not

when i am creating a sub-task this is the error actually encountered me..

 

""Could not find issue by id or key.""

 

this is the main error i am getting please resolve it immediately pls waiting for it,... help me somebody.

Parker Van Dyk February 20, 2019

Please replace 

 'parent' : { 'id' : rootnn.key},

 with

 'parent' : { 'key' : rootnn.key},
Like 2 people like this
0 votes
Matt Doar
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.
April 16, 2013

See https://answers.atlassian.com/questions/49433/creating-sub-task-of-an-issue-using-rest-api for the fields to set and then use the regular create_issue() function.

maxandersen April 16, 2013

I figured it out. Had a bad delete that was failing covering up the error. i'll post answer.

maxandersen April 16, 2013

I tried this in many various combinations but no luck.

rootnn_dict = {

'project' : { 'key': 'JBIDE' },

'summary' : 'Test chfild auto created issue',

'description' : 'Igfnore this child. will be deleted shortly',

'issuetype' : { 'id' : '5' },

'parent' : { "id" : rootnn.key},

}

child = jira.create_issue(fields=rootnn_dict)

where rootnn.key is a valid parent *key*, not just id as stated on your link.

But the last child creation fails.

G V Shabareesh October 10, 2018

when i am giving issue type as 5 it is saying that give the proper issue type..please help me.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events