Error parentId: Given parent issue does not belong to appropriate hierarchy

I try to create two linked issues using the “parent” field via Jira REST API. This works fine if the parent issue has the preinstalled issue type called “Epic” and if the child has the preinstalled issue type “Story”.

But if I try to make a different issue type to be the parent, I am getting this error: Given parent issue does not belong to appropriate hierarchy.

Alright, of course I know there is an issue hirarchy which connects Epics and Stories. But how can I use the parent field for other issue types? or
how can I know if a certain issue type can be used as parent or not before getting this error?

Or is the preinstalled Epic type the only one to be used as parent?

Flower - Process Automation

Did you configure the issue Hierarchy in Jira, and is the issue type of the “parent” issue one level above the current issue?

thank you @david2 - this was the important hint :wink:

I found the issue.fields.issuetype.hierarchyLevel field. This means I have to check this rule, before creating the child issue:

childIssue.fields.issuetype.hierarchyLevel < parentIssue.fields.issuetype.hierarchyLevel

as long as the parent issue type has a higher hierarchyLevel than the child, they can be linked using the parent field, right?

Not sure you can link to a parent that’s not exactly one level up.

of course you are right, so the rule must be:

childIssue.fields.issuetype.hierarchyLevel+1 === parentIssue.fields.issuetype.hierarchyLevel

just want to confirm, this rule works and works even for sub-tasks, which have hierarchyLevel == -1

looks like the field hierarchyLevel is not available in DC REST api. How does hierarchies/parent link work in DC? is there any documentation?