Skip to Content
avatar image
Former Member

Problem in calling POST Service form XSJS

Hello All,
I'm trying to call a POST REST API from my xsjs service but I'm getting the following error - HttpClient.getResponse: Can't get the response from the server: no response is pending...you have to issue a request() first

Given below is my destination and xsjs file

http_dest

host = "https://l5471-iflmap.hcisbp.us2.hana.ondemand.com"; pathPrefix = "/http"; port = 467; proxyType = http; proxyHost = "proxy"; proxyPort = 8080; authType = basic; useSSL = false; sslHostCheck = false;

Test.xsjs

try{ var destination; var client;

destination = $.net.http.readDestination("DFT.RulesProject","http_dest");

client = new $.net.http.Client();

var request = new $.net.http.Request($.net.http.POST,"/commonemail");

request.headers.set("Content-Type" , "application/json");

request.headers.set("Accept" , "application/json");

request.setBody(JSON.stringify( { "mailParam":{ "emailBody": "emailBody", "emailSubject": "emailSubject", "to": "shubham.apatidar@incture.com" }}));

client.request(request, destination);

$.response.setBody(JSON.stringify( {

"Success": client.getResponse().status, "Code" : client.getResponse() } ));

}

catch(e){ $.response.status = $.net.http.INTERNAL_SERVER_ERROR; $.response.setBody(e.message ); }

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 01 at 12:49 PM

    In your host you have HTTPS://. You shouldn't put the protocol there but only the hostname. Also if you have https really as part of the target then why do you have useSSL = false?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I've given all the authentication credentials in XS Admin and have imported the SSL certificate but still I', facing these issue.