I'm searching JIRA using REST API and trying to get subtask name (summary)
whole code is here: https://1drv.ms/u/s!AizscpxS0QM4hJpFPnbeAexYPwYu9Q
I need from this section in file to get summary (Remove user account in Local AD)
whole code is here: https://1drv.ms/u/s!AizscpxS0QM4hJpFPnbeAexYPwYu9Q
I need from this section in file to get summary (Remove user account in Local AD)
"subtasks": [ { "fields": { "issuetype": { "avatarId": 10316, "description": "The sub-task of the issue", "iconUrl": "https://jira.corp.company.com/secure/viewavatar?size=xsmall&avatarId=10316&avatarType=issuetype", "id": "10101", "name": "Sub-task", "self": "https://jira.corp.company.com/rest/api/2/issuetype/10101", "subtask": true }, "priority": { "iconUrl": "https://jira.corp.company.com/images/icons/priorities/medium.svg", "id": "3", "name": "Medium", "self": "https://jira.corp.company.com/rest/api/2/priority/3" }, "status": { "description": "", "iconUrl": "https://jira.corp.company.com/", "id": "10000", "name": "Backlog", "self": "https://jira.corp.company.com/rest/api/2/status/10000", "statusCategory": { "colorName": "blue-gray", "id": 2, "key": "new", "name": "To Do", "self": "https://jira.corp.company.com/rest/api/2/statuscategory/2" } }, "summary": "Remove user account in Local AD" },I tried:
import os import csv import urllib2 import argparse import json from bson import json_util #password = str(sys.argv[1]) headers = { 'Content-Type': 'application/json', } params = ( ('jql', 'project="Technology" AND summary~"workspace creation*" AND issuetype="Task" AND status!="DONE"'), ) response = requests.get('https://jira.corp.company.com/rest/api/2/search', headers=headers, params=params, auth=('user', 'pass;)) data = response.json() for issue in data['issues']: print issue['fields']['subtasks']['summary']i get:
Error: print issue['fields']['subtasks']['summary']
TypeError: list indices must be integers, not str
same with:Error: for i in range (0, len (data['issues'])):
print data['issues']['fields']['subtasks'][i]['fields']['summary']
TypeError: list indices must be integers, not str