Forums

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

Unable to get parent field of an issue

mitra August 10, 2022

I am using Jira API with Python to loop through issues (which are all tasks) and have been referencing their fields (like singleIssue.fields.summary, singleIssue.fields.created, etc). I can't however figure out how to get the parent/epic of the task. It seems like parent should be a field of each issue, but when I display the fields (singleIssue.raw['fields']), parent or epic isn't one of them. Is there anything I am missing here or another way to find the parent of an issue with Python?

2 answers

0 votes
Nic Brough -Adaptavist-
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.
August 10, 2022

The hierarchy is a bit of a mess in Jira, for historical reasons I won't bore you with.  Atlassian are currently trying to improve it, but it's not quite there yet.

Part of it is because of the two styles of project there are.  Both see "Epic -> Issue -> Sub-task" as the core hierarchy, but:

  • Team Managed Projects have a relatively simple "parent / child" structure.
  • Company Managed Projects use "sub task links" to connect issues to sub-tasks and Epic Link to link issues to Epics.

Atlassian are moving the REST APIs to hide the complexities of CMPs here, and you will soon be able to just say "parent/child" and not have to worry, but for now, you do need to look at the project type to work out what you should be asking for!

mitra August 11, 2022

Got it - thanks for your answer that makes sense! How would I know which one my project is?

0 votes
KJ
Contributor
August 10, 2022

Have you tried parentID or parent.id?

You can see all of the fields on an issue by typing this in a browser. (I also have a browser extension that makes the JSON pretty.):

https://{instancename}.atlassian.net/rest/api/latest/issue/{issuekey}

When I do that for a Story related to an Epic, I see this in the results:

  • expand: "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations,customfield_10017.requestTypePractice,customfield_10202.properties",
  • id: "254578",
  • self: "https://{instancename}.atlassian.net/rest/api/latest/issue/254578",
  • key: "AA-2930",
  • fields: {
    • parent: {
      • id: "179956",
      • key: "AA-756",
      • self: "https://{instancename}.atlassian.net/rest/api/2/issue/179956",
      • fields: {
        • summary: "Support/Consultation",
        • status: {
          • self: "https://{instancename}atlassian.net/rest/api/2/status/3",
          • description: "This issue is being actively worked on at the moment by the assignee.",
          • iconUrl: "https://{instancename}atlassian.net/images/icons/statuses/inprogress.png",
          • name: "In Progress",
          • id: "3",
          • statusCategory: {
            • self: "https://{instancename}atlassian.net/rest/api/2/statuscategory/4",
            • id: 4,
            • key: "indeterminate",
            • colorName: "yellow",
            • name: "In Progress"
            }
          },
        • priority: {},
        • issuetype: {
          • self: "https://{instancename}.atlassian.net/rest/api/2/issuetype/10000",
          • id: "10000",
          • description: "A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.",
          • iconUrl: "https://{instancename}.atlassian.net/images/icons/issuetypes/epic.svg",
          • name: "Epic",
          • subtask: false,
          • hierarchyLevel: 1
mitra August 11, 2022

Thanks so much for your response! When I look at https://{instancename}.atlassian.net/rest/api/latest/issue/{issuekey}, I don't see any fields related to "parent" or "epic", but when I look at https://{instancename}.atlassian.net/rest/api/latest/issue/{issuekey}?expand=names I see a parent field with id, key, summary, and more. I'm new to this so this may be an obvious question, but what does the ?expand=names in the URL do and how would I access those fields in my loop?

Suggest an answer

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

Atlassian Community Events