I have an app that makes a makeWebRequest to an HTTP server to get JSON Data. The current version (published) is working. I'm trying to make some changes but the call to makeWebRequest fails with error -400 (INVALID_HTTP_BODY_IN_NETWORK_RESPONSE) on the simulator.
I made some tests and finally find out that I only get this error if the HTTP Server returns "text/json; charset=UTF-8" as Content-Type. It woks if the server only says "text/json". Of course I can't change the server !
The "charset=UTF-8" raises the issue !...
I googled around but did not find any hint. Could someone help me ?
Here is the code I use :
[FONT=courier new]var params = {
"keyapp" => "xxxxxx", // API key
"dataFormat" => "json",
"id" => id
};
var headers = {
// body will be encoded as 'a=1&b=2'
"Content-Type" => Comm.REQUEST_CONTENT_TYPE_URL_ENCODED,
// Force user agent
"User-Agent" => UserAgent,
// Accept encoding
"Accept-Encoding" => "identity",
// accept responses that are reported as json-compatible
"Accept" => "application/json"
};
var options = {
:method => Comm.HTTP_REQUEST_METHOD_GET,
:headers => headers,
:responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_JSON
};
Comm.makeWebRequest(
URL,
params,
options,
method(:onReceive)
);[/FONT]
Thanks !