How to from either command line or the rest API to traverse and found all parents of a work item
2 answers
There can only be one parent. See https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/
If you are using OSLC API, namely, accessing the work item via the URL such as /ccm/resource/itemName/com.ibm.team.workitem.WorkItem/114, you can find the parent work item in two places within the response body.
1. In the <Description> itself.
<rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.parent rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/43" />
2. In a separete "node".
<rdf:Description rdf:nodeID="A4">
<rdf:subject rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/114"/>
<rdf:predicate rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/com.ibm.team.workitem.linktype.parentworkitem.parent"/>
<rdf:object rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/43"/>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"/>
<dcterms:title>43: Implement - Requests sent in form of email</dcterms:title>
</rdf:Description>
If you are using the reportable REST API, you can query the parent directly using the URL such as
/ccm/rpt/repository/workitem?fields=workitem/workItem[id=114]/parent/*.
You can even get the grandparent, great-grandparent in the same query if you so desire
/ccm/rpt/repository/workitem?fields=workitem/workItem[id=114]/(id|summary|parent/(id|summary|parent/(id|summary|parent/(id|summary)))).
1. In the <Description> itself.
<rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.parent rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/43" />
2. In a separete "node".
<rdf:Description rdf:nodeID="A4">
<rdf:subject rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/114"/>
<rdf:predicate rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/com.ibm.team.workitem.linktype.parentworkitem.parent"/>
<rdf:object rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/43"/>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"/>
<dcterms:title>43: Implement - Requests sent in form of email</dcterms:title>
</rdf:Description>
If you are using the reportable REST API, you can query the parent directly using the URL such as
/ccm/rpt/repository/workitem?fields=workitem/workItem[id=114]/parent/*.
You can even get the grandparent, great-grandparent in the same query if you so desire
/ccm/rpt/repository/workitem?fields=workitem/workItem[id=114]/(id|summary|parent/(id|summary|parent/(id|summary|parent/(id|summary)))).