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

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

$
0
0

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);

}


Viewing all articles
Browse latest Browse all 3131

Trending Articles



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