Using expand=renderedFields with Python

mitra August 11, 2022

While trying to figure out how to access the parent field of an issue, I realized that the "parent" field doesn't come up with the URL https://{instancename}.atlassian.net/rest/api/latest/issue/{issuekey} but it does come up for the URL https://{instancename}.atlassian.net/rest/api/latest/issue/{issuekey}?expand=names or https://{instancename}.atlassian.net/rest/api/latest/issue/{issuekey}?expand=renderedFields. Both of those URLs have a fields section that looks like this

Screen Shot 2022-08-11 at 10.45.50 AM.png

After realizing this, I added these lines of code, which are in a loop that loops through all the issues

myIssue = jira.issue(singleIssue.key, expand='renderedFields')
parentsummary.append(myIssue.fields.parent)

But it still says parent doesn't exist within myIssue, and I even printed all the fields of myIssue to check and parent wasn't there. Did I use expand incorrectly? Is there another way to access parent?

1 answer

0 votes
Dmitry Elsakov August 11, 2022

Looks like you are using JIRA library to get values.

Please check with the version of that library OR maybe check some alternatives.

Also, just to check if fields ARE available, you could use very simple approach:

import requests

response = requests.get('https://{instancename}.atlassian.net/rest/api/latest/issue/{issuekey}?expand=renderedFields')
result = response.json()
print(result['fields']['parent'])

NOTE: For me jira library returned 'parent' just in fields, like

from jira import JIRA

jira_connection = JIRA(.... - <URL + Auth params>) 

issue = jira_connection.issue('some issue key')
parent_key = issue.fields.parent.key

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events