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

Hana xs

$
0
0

Hello all,

 

I am trying to explore XS service. I have jsonapi, where data updates every few minutes.I am trying to import into HANADB. I have created xsjs files and xshttpdest files.I am able to insert the data into HANADB, if I enter values in URL while running xsjs file, for example,

?id=67, I am able see the value under id column, But My requirement is to insert directly from jsonapi into Hanatables.

 

I have also created a table which have only one column (id)

 

When I create following files and trying to run xsjs file, I am getting as

 

data = {'data":[['null']]}

 

Instead of null, it should  show value of id from api.

 

==============

 

google_test.xsjs :

 

========================

 

var dest = $.net.http.readDestination("vinni","google");

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

    var req = new $.web.WebRequest($.net.http.GET, "?id");

   client.request(req, dest);

    var response = client.getResponse();

var id = $.request.parameters.get("id");

if (id === null) {

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

  $.response.addBody("id is null!") ;

  }

  var output = {}; 

  output.data = [];

  var conn = $.db.getConnection();

conn.prepareStatement("SET SCHEMA \"xxxxxxxx\"").execute();

var st = conn.prepareStatement("INSERT INTO \"xxxxx\" values('" + id + "')").execute();

 

conn.commit(); 

  var record = [];

  record.push(id);

  output.data.push(record); 

 

  $.response.contentType = "application/json";

  $.response.setBody(JSON.stringify(output));

 

=======================

google.xshttpdest file:

 

========================

 

host = "abc.xxxx.com";

port = 80;

pathPrefix = "/xxxxxxxxx.json";

proxyType = http;

proxyHost = "proxy";

proxyPort = 8080;

authType = basic;

useSSL = false;

timeout = 30000;

 

====================

 

Could you please help me out from this issue.

Thanks


Viewing all articles
Browse latest Browse all 3131

Trending Articles



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