Unable to call the API

Hi,

Below is our code and we are unable to call the API, issue lies with the headers.

// Define the URL
var url = "https://fqdn:13443/SM/7/IncidentManagement.wsdl";

 

// Define the headers array and add the "Cookie" header
var headers = [
    ["Cookie", "sails.sid=s%3AjrjtzQhAlmZX319NMKj4qQh2f5N8FO5n.1bKW9%2FSQ6Be6y3DgnYxJtVZ9SopZSzDpjyxWmNU%2FHKk"]
];

 

var WSDLrequest;
var reply;
var respHeaders = new Object();

 

try {
    // Make the HTTP GET request
    WSDLrequest = doHTTPRequest("GET", url, headers, null, 10, 10, null, respHeaders);

 

    // Print response headers
    print("The response headers of the doHTTPRequest are:");
    for (var name in respHeaders) {
        print(name + "=" + respHeaders[name]);
    }

 

    // Print the result of the doHTTPRequest
    print("The result of the doHTTPRequest is:\n" + WSDLrequest);

 

    // Write the response body to a file
    reply = writeFile("C:\\IncidentManagement.wsdl", "text", WSDLrequest);
} catch (e) {
    // Handle exceptions
    print("WSDL request failed with exception:\n" + e);
}

BR,

Haniyya Rehan

Parents Reply Children
  • 0 in reply to   

    Hi Simon,

    Below is my code:

    var url = "">https://postman-echo.com/get";
    //var headers = [
    // ["Cookie", "sails.sid=s%3AjrjtzQhAlmZX319NMKj4qQh2f5N8FO5n.1bKW9%2FSQ6Be6y3DgnYxJtVZ9SopZSzDpjyxWmNU%2FHKk"]
    //];

    //Content-Type

    var contentHeader = new Header();
    var headers = new Array();
    contentHeader.name = "Content-Type";
    contentHeader.value = "application/json";
    headers.push(contentHeader);

    var WSDLrequest;
    var respHeaders = new Object();

    try {
    WSDLrequest = doHTTPRequest("GET", url, headers, null, 10, 10, respHeaders);
    print("The response headers of the doHTTPRequest is:");
    for (var name in respHeaders) {
    print(name + "=" + respHeaders[name]);
    }
    print("The result of the doHTTPRequest is \n" + WSDLrequest);
    } catch (e) {
    print("WSDL request failed with exception \n" + e);
    }

    Following is error that I am experiencing: