Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2895

Re: How can I call XS REST API from xsjs?

$
0
0

Hi Thomas,

 

 

I  am facing a similar issue. Can you please help me on this.

 

Below are the related xsjs file and xshttpdest file which i am using to create a file in repository.

 

 

Here is the xsjs file.

 

 

var destn_pkg = "X";

var dest_name = "image_load";

try

{

 

 

  var dest = $.net.http.readDestination(destn_pkg, dest_name);

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

  var req = new $.web.WebRequest($.net.http.POST,"");

 

   var oSapBackPack = { 'Active': 'true' };

  var sapBackPack = JSON.stringify(oSapBackPack);

  req.headers.set("SapBackPack", sapBackPack);

  //, "/httpdest.png");

  client.request(req, dest);

  var response = client.getResponse();

  var body12 = response.body.asString();

  $.response.status = $.net.http.OK;

  $.response.contentType = "text/plain";

  $.response.setBody('body12 ');

 

 

}

 

  catch (e) {

  $.response.contentType = "text/plain";

  $.response.setBody(e.message);

 

 

}

 

 


Httpdest file is this :



host = "<accountname>.hana.ondemand.com";

port = 80;

pathPrefix = "/sap/hana/xs/dt/base/file/AEM/img/test12.png";

proxyType = http;

proxyHost = "proxy";

proxyPort = 8080;

authType = basic;

useSSL = false;

timeout = 3000;

 

 

 

 

 

I have maintained the authentication in XSAdmin.

 

 

Response body is undefined for me

 

Can you please help me to resolve this.

 

 

Thanks a ton in advance.

 

 

 

 

Thanks and Regards,

Poorna


Viewing all articles
Browse latest Browse all 2895

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>