Skip to Content

To change pathPrefix in xshttpdest dynamically (Hana XSJS)

Dear All,

Our vendor exposed us a standalone API to check payload status. To achieve this, we need to pass Payload ID as part of pathPrefix in xshttpdest. Can you please suggest of any provision to change pathPrefix dynamically please ?

Thank You.

Add comment
10|10000 characters needed characters exceeded

  • Why you need to store the payload ID in the pathPrefix instead of adding it to the request as normally done with parameters which value will change?

    Regards,
    Florian

  • Hi Florian,

    Thank you for prompt response. https://abcd.com/API/"payload_id"/status is the API we need to call to receive payload status. We shall be passing payload id depending on which import status we want to check. I am storing https://abcd.com as host and /API/"payload_id"/status as pathPrefix in xshttpdest file. Can I pass parameter values to xshttpdest as well ? I wasn't aware ! How do I pass payload id parameter value to pathPrefix dynamically please ? Sorry if you meant of doing it another way and I did not happen to understand.

    Thanks

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 18, 2017 at 04:48 AM

    Just store the "/API" as pathPrefix in your xshttpdest file if you wanna do that. Than add the "dynamic" partof the URLwhen you create the request in your XSJS service.

    You can have a look to the example in the XSJS API Reference.

    A simple example for your case (with random choosen values for the destination as I do not know your names :)).

    let dest = $.net.http.readDestination("com.test.dummyapplication", "dummyDestination");
    let payloadID = "ABCD1000";
    let dynamicURLPart = "/" + payloadID + "/status";
    var request = new $.net.http.Request($.net.http.GET, dynamicURLPart); // -> this results in an URL https://abcd.com/API/ABCD1000/status for the request when "/API" is defined as path prefix in your xshttpdest file

    Regards,
    Florian

    Add comment
    10|10000 characters needed characters exceeded