Get module structure URI via rest API
I want to get the module structure in json format using REST API in DNG version 7.0.2. I have referred to the page here: https://jazz.net/wiki/bin/view/Main/DNGModuleApiScenario2
But I am stuck because I am unable to get the module structure URI. (For e.g: https://clmwb.com:9444/rdm/resources/_4sscEb43EeeD0-df1VhHuw/structure)
Could someone please help me on how to get this URI via REST API?
Accepted answer
Hi
For the module structure API it's important to:
- Don't construct the structure URL, get it from the module definition by doing a GET on the module URL using the following settings:
- Provide header (capitalised exactly like this)
- DoorsRP-Request-Type: public 2.0
- Do NOT provide header OSLC-Core-Version
- Provide the configuration using header vvc.configuration and NOT using header Configuration-Context or query ?oslc_config.context - so it must be a local configuration URL not a global configuration
Once you've done the GET the XML includes the structure URL like:
- <j.1:structure rdf:resource="https://jazz.ibm.com:9443/rm/resources/MD__y90_0B6Eeuh3Iiax2L3Ow/structure"/>
- (j.1 namespace is http://jazz.net/ns/rm/dng/module#)
For 7.0.2 I'd expect the UUID part of your module URL to start with MD_ as shown above - you can get this link through the browser by finding the module and then Share link to artifact.
When you GET the structure URL use the same headings as the first GET (i.e. for RDF), the result will be like:
<rdf:RDF
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:oslc_core="http://open-services.net/ns/core#"
xmlns:oslc_config="http://open-services.net/ns/config#"
xmlns:nav="http://com.ibm.rdm/navigation#"
xmlns:jazz_rm="http://jazz.net/ns/rm#"
xmlns:j.0="http://jazz.net/ns/rm/dng/module#"
xmlns:rm_types="http://www.ibm.com/xmlns/rdm/types/"
xmlns:process="http://jazz.net/ns/process#">
<j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/MD__y90_0B6Eeuh3Iiax2L3Ow/structure">
<j.0:childBindings rdf:parseType="Collection">
<j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/BI__yq5skB6Eeuh3Iiax2L3Ow">
<j.0:isHeading rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean"
>true</j.0:isHeading>
<oslc_config:component rdf:resource="https://jazz.ibm.com:9443/rm/cm/component/__J_JEEB6Eeuh3Iiax2L3Ow"/>
<j.0:boundArtifact rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX__0wkYUB6Eeuh3Iiax2L3Ow"/>
<j.0:module rdf:resource="https://jazz.ibm.com:9443/rm/resources/MD__y90_0B6Eeuh3Iiax2L3Ow"/>
<j.0:childBindings rdf:parseType="Collection">
<j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/BI__yq5s0B6Eeuh3Iiax2L3Ow">
<j.0:isHeading rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean"
>false</j.0:isHeading>
<oslc_config:component rdf:resource="https://jazz.ibm.com:9443/rm/cm/component/__J_JEEB6Eeuh3Iiax2L3Ow"/>
<j.0:boundArtifact rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX__2GBIkB6Eeuh3Iiax2L3Ow"/>
<j.0:module rdf:resource="https://jazz.ibm.com:9443/rm/resources/MD__y90_0B6Eeuh3Iiax2L3Ow"/>
<j.0:childBindings rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</j.0:Binding>
<j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/BI__yq5tEB6Eeuh3Iiax2L3Ow">
<j.0:isHeading rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean"
>true</j.0:isHeading>
<oslc_config:component rdf:resource="https://jazz.ibm.com:9443/rm/cm/component/__J_JEEB6Eeuh3Iiax2L3Ow"/>
<j.0:boundArtifact rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX__0dCdUB6Eeuh3Iiax2L3Ow"/>
<j.0:module rdf:resource="https://jazz.ibm.com:9443/rm/resources/MD__y90_0B6Eeuh3Iiax2L3Ow"/>
<j.0:childBindings rdf:parseType="Collection">
<j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/BI__yq5tUB6Eeuh3Iiax2L3Ow">
<j.0:isHeading rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean"
....
If you get the structure with Accept: application/json you get a, err, JSON structure looking like this:
[ {
"type" : "dng_module:Binding",
"isStructureRoot" : "true",
"isHeading" : false,
"boundArtifact" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",
"childBindings" : [ "https://jazz.ibm.com:9443/rm/resources/BI__yq5skB6Eeuh3Iiax2L3Ow", "https://jazz.ibm.com:9443/rm/resources/BI__yq5vEB6Eeuh3Iiax2L3Ow", "https://jazz.ibm.com:9443/rm/resources/BI__yq52kB6Eeuh3Iiax2L3Ow" ]
}, {
"type" : "dng_module:Binding",
"isHeading" : true,
"boundArtifact" : "https://jazz.ibm.com:9443/rm/resources/TX__0wkYUB6Eeuh3Iiax2L3Ow",
"childBindings" : [ "https://jazz.ibm.com:9443/rm/resources/BI__yq5s0B6Eeuh3Iiax2L3Ow", "https://jazz.ibm.com:9443/rm/resources/BI__yq5tEB6Eeuh3Iiax2L3Ow", "https://jazz.ibm.com:9443/rm/resources/BI__yq5t0B6Eeuh3Iiax2L3Ow", "https://jazz.ibm.com:9443/rm/resources/BI__yq5ukB6Eeuh3Iiax2L3Ow" ]
}, {
"type" : "dng_module:Binding",
"isHeading" : false,
"boundArtifact" : "https://jazz.ibm.com:9443/rm/resources/TX__2GBIkB6Eeuh3Iiax2L3Ow",
"childBindings" : [ ]
}, {
"type" : "dng_module:Binding",
....
API documentation is here https://jazz.net/wiki/bin/view/Main/DNGModuleApiOverview
There's a Python example of accessing the module structure which as a demonstration prints out the indented content and section number in my public OSS package here https://github.com/IBM/ELM-Python-Client/blob/master/elmclient/examples/dn_simple_modulestructure.py
HTH
Ian
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Nov 29 '21, 4:46 a.m.Check the URI root. it ends with 'rdm' and not with 'rm' so it is likely not a requirement module and has no module structure.