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
  • 0  

    Hi Haniyya

    Would you please to try this http header?

    //Content-Type
    var contentHeader = new Header();
    contentHeader.name = "Content-Type";
    contentHeader.value = "application/json";
    headers.push(contentHeader);
    //Auth
    var authHeader = new Header();
    authHeader.name = "Authorization";
    authHeader.value = "Basic " + lib.smis_CommonLib.encode64("falcon" + ":" + "*********?");
    //Construct Header
    headers.push(authHeader);

    I t hink the headers is not correct.

    Thanks

  • 0 in reply to   

    Hi Simon,

    Thank you for your reply.

    But I am still experiencing the  "ReferenceError: headers is not defined".

    BR,

    Haniyya Rehan 

Reply Children