Skip to Content

Consume Http destination in xsjs file in XSA Advanced Application

Mar 13 at 02:56 PM


avatar image

Hello all!

I'm developing an xsa advanced application and I would like to consume an API through an xsjs file, but I find myself unable to find the right way to do it.

I read that it is possible to create an http destination, but I can't make it to work.

Does anybody know how to consume an API through an xsjs file?

I'm using Hana express edition with its webIDE.

Thanks a lot!

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

1 Answer

Best Answer
Steven De Saeger 2 days ago


A similar functionality is part of the openSAP HANA XSA SPS02 course excercises ... in there an HTTP call is made via xsjs ...

Basically you need to register an user provided service with the HTTP settings, define the resource in the mta and require it in your xsjs module. Then you can access it in your code:

var dest = $.net.http.readDestination("", "images.SDS");     
var client = new $.net.http.Client();     
var req = new $.web.WebRequest($.net.http.GET, search);     
client.request(req, dest);     
var response = client.getResponse();

The exercises can be found on GitHub at HANA XSA SPS02 - have a look at the ZIP file and in there at the file 'outboundTest.xsjs'.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thank you for the answer!

I had already created the xshttpdest file and required it in the xsjs, but I don't know how to register the service, some places say I have to register an http destination via de xs admin tools, but I can't find it.

Also, when you talk about defining the resource in the mta, how should I do that?

I'm using the Hana express edition.

Thank you very very much!


Hi David,

Registration can be done via the command line tool - make sure you are in your own space


xs cups <your user provided service name> -p '{ "host": "<url>", "port": "<port>", "tags": ["xshttpdest"] }'

Do a search on the xs cups command and you will find the details.

Once that ran the service should be visible when you run xs services

Declaring the resource can be done via the webide - just open the mta file and go to the resources tab.

Do a search on XSA tutorials and you will find plenty of examples on how to configure the mta yaml file ... you will need to do this for every resource you want to use when developing in the XSA MTA model.