Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

How can I call XS REST API from xsjs?

$
0
0

Hello Colleagues,

 

I am trying to modify file content and activate it by using and xsjs and the XS REST API. For this purpose I am using the HTTP Outbound API and after making the http request, the response is always an http code 303 with HANA login URL as "location" parameter.

 

I am sending into the header the CSRF token but it seems it is not enough for authentication.

 

My real question is: How can I give to the request the proper credentials? Is there something that I am doing wrong?

 

Here is a piece of the code:

 

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

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

  var sapBackPack = JSON.stringify(oSapBackPack);

  var dest = $.net.http.readDestination("MyProject.services", "XS_REST_API");

 

  var CSRF = $.session.getSecurityToken();

 

  var request = new $.web.WebRequest($.net.http.GET, "");

 

  // Header parameters

  request.headers.set("Orion-Version", "1.0");

  request.headers.set("X-CSRF-Token", CSRF);

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

 

  client.request(request, dest);

  var response = client.getResponse();


  return response.body.asString();

 

 

Path in XS_REST_API.httpdest:

 

pathPrefix = "/sap/hana/xs/dt/base/file/MyProject/test_rest_api.txt";


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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