cancel
Showing results for 
Search instead for 
Did you mean: 

unsupported charset specified in Content-Type header (""UTF-8"")

Pascal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello,

I want to query an external service to get the exchange rates from a currency1 to a currency2 at a certain date.

Service: http://currencies.apps.grandtrunk.net/getrate/2013-03-27/CHF/EUR

This returns a value and works smooth.

I found following example here, which works fine to do a server side javascript query to an external service:

https://help.hana.ondemand.com/help/frameset.htm?a238abbe7bb141f1a66143da94697b95.html

This works out fine, too.

But if I want to do it similar like that example, I get following error: “Body.asString : unsupported charset specified in Content-Type header (""UTF-8"")”

We (as i already discussed that with many colleagues) think this is due to the double quotes and xsjs has a bug on this ... but anyhow any help is appreciated. Thanks!

Here are my 2 files, similar to the example mentioned above:

service_exchangerate.xshttpdest:
host = "http://currencies.apps.grandtrunk.net";
port = 80;

description = "Get Exchangerate by date and source-/target currency";
useSSL = false;
pathPrefix = "/getrate";
authType = none;
useProxy = true; 
proxyHost = "proxy-trial"; 
proxyPort = 8080; 
// useProxy = false;
// proxyHost = "";
// proxyPort = 0; timeout = 0;

getExchangerate.xsjs:
var destination_package = "<my.path.to.hanaxs.app>.services";
var destination_name = "service_exchangerate";
var querydetail = "/2013-03-27/CHF/EUR";
try {

var dest = $.net.http.readDestination(destination_package, destination_name);      
var client = new $.net.http.Client();       
var req = new $.web.WebRequest($.net.http.GET, querydetail);      
client.request(req, dest);       
var response = client.getResponse();            
$.response.contentType = "application/json";       
$.response.setBody(response.body.asString());       
$.response.status = $.net.http.OK;

}
catch (e) {     

$.response.contentType = "text/plain";       
$.response.setBody(e.message);

}

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I tested your code and destination from my HANA system. It works perfectly fine:

The only change I made was in your HTTP Destination file. You had HTTP:// on the front of the hostname. This was producing an connection error when it was specified that way. I removed the http:// and then everything worked just fine.

Former Member
0 Kudos

Hi Thomas,

Can we do SAP HANA Cloud Platform Trial Server connectivity with  On-premise.??

Also, please help me with this thread:

Thanks

Kapil Jain

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Kapil,

ahem, what does your question have to do with the topic of this thread?! Why are you posting your questions all over this website in threads that are completely unrelated to your own problem? I find this a bit annoying. If you want to ask someone particular for help, then just send him a "Direct Message", instead of misusing other threads like this...

Best Regards, Ulrich

Answers (2)

Answers (2)

vivek_agrawal2
Participant
0 Kudos

I have also created a .xshttpdest where i have not used "http://" in file in our application hosted on HCP where I am fetching the data from a WCF REST Service. But even then i am receiving the above error.

Please suggest any solution for the error.

Pascal
Product and Topic Expert
Product and Topic Expert
0 Kudos

noone?


My workaround is now to do the request/response via a Java Servlet, but I think that is just second best solution?