How to get the URI of a newly created delivery session via API in DNG?
I create a new delivery session via API using following code:
fetch("/rm/delivery-sessions",{
method: "POST",
headers: {"Accept":"rdf+xml",
"OSLC-Core-Version": "2.0",
"Content-type": "application/rdf+xml",
"Configuration-Context": changeSetUri
},
body: rdfDataPost
})
.then((headers)=> {console.log (headers)
console.log (headers.location)
console.log (headers.ok)
console.log (headers.statusText)
})
As answer I retrieve the response:
headers.ok = 201 and
headers.statusText = created
But no URI in it. The (headers.location is undefined).
In the documentation I found following: "The server may respond with an error code, or, 201 CREATED.
- 201 CREATED: The request was completed. The Location response header contains the uri of the newly-created delivery session resource."
If I use the development tools of the browser. I can see in the "Network" tab the new delivery session URI: Location:
But I can not see in the console any URI of the delivery session in it.
Have anybody an idea how I can get the new delivery session URI also in my javascript code?
Thank you in advance.
Accepted answer
I did some coding for this a while ago and I used the location header of the response. The code is here: https://github.com/jazz-community/dng-type-system-management/blob/master/com.ibm.rm.typemanagement/src/main/java/com/ibm/requirement/typemanagement/oslc/client/resources/DngCmDeliverySession.java#L267
So in case of the 201 you get the header Location from the response, that should contain the URI.