Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes


Accepted answer

Permanent link

 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

0 votes


One other answer

Permanent link

Dear Ralph,


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

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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jan 08, 7:08 a.m.

Question was seen: 653 times

Last updated: Jan 08, 9:37 a.m.

Confirmation Cancel Confirm