Skip to Content
0
Former Member
May 01, 2018 at 05:47 AM

Problem in calling POST Service form XSJS

1133 Views

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