Skip to Content

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

Hi Experts,

Step 1:

Created a file cloud_wf.xshttpdest as below:

description = "Cloud Workflow";
host = "";
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");
    // do nothing
    // handleErrors(response);
    return response.headers;
return CSRF;


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);


{"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":""},"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.


xs-admin-tool.jpg (50.4 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Oct 16, 2019 at 01:02 PM

    Hi Sabarna,

    I suppose the

    useSSL = false;

    makes your call a plain HTTP call. However, CP Workflow is not available through unencrypted channels like plain HTTP (I think that's true for basically all CP services).

    Therefore, you get a redirect to the HTTPS location. That means you need to set useSSL = true and maybe do further security configuration.



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 18, 2019 at 05:51 AM

    I am not an XS expert. I just suggested to judge the problem by the exact error message, not by the status code 500.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 18, 2019 at 02:22 PM

    Just to Update, Changed the Port to - 443.

    result :

        "0": {
            "name": "~response_line",
            "value": "HTTP/1.1 502 Connection reset by peer"
        "1": {
            "name": "~server_protocol",
            "value": "HTTP/1.1"
        "2": {
            "name": "~status_code",
            "value": "502"
        "3": {
            "name": "~status_reason",
            "value": "Connection reset by peer"
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.