Intro
I recently needed to collect data from external websites in json format using SAP HANA. There were some very useful blogs on scn to help me find my way. I however did notice that most of them were prior to SP09 and I therefore had one or two challenges trying to complete this as the user interface has changed slightly on HANA on the admin side. This blog will provide a more up to date reference but also share what blogs assisted me along the way.
Simple http request
So to create a simple app to communicate with the web I looked at SAP Help and found the following SAP HANA Cloud Platform
I found this helpful as it had simple code and worked with json.
Below is an example of taking the code from the example, you need to create a xshttpdest file as shown below.
Then create a xsjs file with the following code. Note that httpdest and xsjs file must be in the same directory.
You can now run the program, it will connect to google maps api. The example requests a distance calculation from Cologne in Germany to Frankfurt in Germany.
The output is in json format and in my screen it has come out in a neat structure, that is because I have app in my google chrome that does this for me. Depending on the browser the output can vary.
More Complex http request
So some sites when connecting it will be a secure website and uses https instead of http. In these instances in order to interact with the websites you will need a certificate to allow secure communication.
I found some very good blogs on this on scn by kai-christoph.mueller , they are
Outbound httpS with HANA XS (part 1) - set up your HANA box to use SSL/TLS
Outbound httpS with HANA XS (part 2) - set up the trust relation
This was an excellent starting point for me, I however did have the following challenges
I have intentionally smeared my bearer credentials. This is the authentication with twitter for my twitter account.
If you now run the application it will connect to twitter and search for SAP HANA tweets, will return search results in JSON as shown below.
Conclusion
The https can be more complex as linking the code to certificate is done in separate section. But once you know where to go and how to do it, it is then relatively simple.
I hope the above helps anyone trying to connect to HTTP from HANA.
Thanks. Good luck :smile:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |