Skip to Content
0
Oct 16, 2019 at 11:35 AM

Response - '302 Found' while accessing 'bpmworkflowruntimewfs' - API from XSJS application.

378 Views Last edit Oct 16, 2019 at 11:40 AM 2 rev

Hi Experts,

Step 1:

Created a file cloud_wf.xshttpdest as below:

description = "Cloud Workflow";
host = "bpmworkflowruntimewfs-pXXXXXXXXXXtrial.hanatrial.ondemand.com";
port = 80;
proxyType = http;
proxyHost = "proxy";
proxyPort = 8080;
authType = basic;
useSSL = false;
timeout = 0;

Then maintained the Authentication details in XS Admin Tool.


Step 2:

Declared a function in file lib.xsjslib:

function getCSRFToken(dest, client){
var req = new $.web.WebRequest($.net.http.GET, '/workflow-service/rest/v1/xsrf-token');
req.headers.set("x-csrf-token", "fetch");
client.request(req, dest);
var response = client.getResponse();
var CSRF = response.headers.get("x-csrf-token");
if(response.status===200){ 
    // do nothing
}
else{
    // handleErrors(response);
    return response.headers;
}
return CSRF;
}

STEP 3:

Then created a file named - test_now.xsjs with the below code -

var dest = $.net.http.readDestination("custom_iot", "cloud_wf");
var client = new $.net.http.Client();
var response = fLib.getCSRFToken(dest, client);
$.response.setBody(JSON.stringify(response));

STEP 4:

{"0":{"name":"~response_line","value":"HTTP/1.0 302 Found"},"1":{"name":"~server_protocol","value":"HTTP/1.0"},"2":{"name":"~status_code","value":"302"},"3":{"name":"~status_reason","value":"Found"},"4":{"name":"location","value":"https://bpmworkflowruntimewfs-pXXXXXXXXXXtrial.hanatrial.ondemand.com/workflow-service/rest/v1/xsrf-token"},"5":{"name":"server","value":"BigIP"},"6":{"name":"content-length","value":"0"},"7":{"name":"proxy-connection","value":"keep-alive"}}

Please let me know why I am getting this Status code as - 302. As the status code is not 200, I am unable to get the generated Token value.

NOTE: This API is already tested from POSTMAN and its Working fine.

Waiting for early response.

# ( SCP + SAP HANA WEB BASED DEVELOPMENT )

Attachments

xs-admin-tool.jpg (50.4 kB)