Skip to Content

how to schedule an outbound http request in XSJS

Mar 28, 2017 at 10:35 PM


avatar image
Former Member

Hi all,

We have some code to do an outbound http call and write te response to a table when we call it manually this works fine. However when I try to automate this in via an xsjob, I keep getting the message: $.response is undefined.

Any help would be greatly appreciated.

Kind regards,

Scott Wery

--partial code below

var destination_package= "remiqz.ETL";
var destination_name= "Exchange_Rate";
function run(){
try {
//Coding for exchange rates import
var dest= $.net.http.readDestination(destination_package, destination_name);
var client= new $.net.http.Client();
var req= new $.web.WebRequest($.net.http.GET, "?base=EUR&symbols=USD,GBP");
client.request(req, dest);
var response = client.getResponse();

$.response.contentType= "application/json";
$.response.status= $.net.http.OK;

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Florian Pfeffer
Mar 29, 2017 at 04:44 AM

Objects like $.response or $.request are not available in background processing. They are only available in case you call the xsjs script via a client (like a browser).

The question is what you wanna really reach. I don't think, that you wanna set the response for a specific client call in background processing.


Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Florian,

Thanks for clarifying again :) The goal here is:

Automatically read a web-service to obtain an exchange rate and store this in HANA.

We currently do not have an SAP ERP installed to read exchange rate tables, so this is why we are looking into a webservice.

Any pointers in how to solve are much appreciated

kind regards, Scott


Ok, to store the data you do not need to return the response you received from client.getResponse() via the $.response object, cause you have no client.

The simplest way would be to use the $.hdb db interface to store the data in your target table.

Maybe it is also an option you to use SAP Landscape Transformation to replicate the required tables to your HANA instance. From my point of view this would be the better solution for that scenario compared to the usage of a web service call.

Former Member

Hi Florian,

The source we are trying to read is only available as a webservice. I am really looking for a way to schedule the call of this webservice and return the data,Writing it back to a HANA is not really our challenge as we did this with a procedure already.

Thanks again,



Then I do not get your situation.

You have created an xsjs script which calls a web service returning some exchange rate information. This script is scheduled via an xsjob. The result is stored in a table.

Why and for what you need the $.response in your script and what you wanna reach in addition to the storage of the data in your db?

Former Member

Hi Florian,
indeed removing $.response fixed it.
Initially we tried this but encountered an error, which led to us trying to try to work with the response.
Thanks again for you help,


Kirill Gorin Mar 29, 2017 at 08:09 AM

You should try to run you XSJS app as XS service

10 |10000 characters needed characters left characters exceeded