It's all about the answers!

Ask a question

How to get the URI of a newly created delivery session via API in DNG?


Antje Rößle-Tuchel (294) | asked Jan 08, 7:08 a.m.

 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


permanent link
Ralph Schoon (63.3k33646) | answered Jan 08, 7:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jan 08, 7:51 a.m.

 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.

Ralph Schoon selected this answer as the correct answer

One other answer



permanent link
Antje Rößle-Tuchel (294) | answered Jan 08, 9:37 a.m.

Dear Ralph,


 Thank you for your answer. With your help I got it:

console.log(headers.headers.get("Location"))


Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.