Hi, I am trying to connect to a web server to receive some data from an external web server. When looking at the HTTP traffic log on the simulator I can see I get an HTTP 200 OK response back and some data in the body. However, when I parse the data in onReceive, its Null and the reponseCode is -400. Here is the code I use:
var headers = {
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON,
"Accept" => "application/json"};
var params = {
"password" => _pwd,
"accountName" => _username,};
var options = {
:method => Communications.HTTP_REQUEST_METHOD_POST,
:headers => headers};
Communications.makeWebRequest(loginURL, params, options, method(:onReceive));
function onReceive(responseCode, data) {
System.println("ResponseCode: " + responseCode);
System.println("Data: " + data);
}
The reponseCode I get in onReceive is -400 and data is Null.
When I look at the HTTP traffic log in the Simulator I see this:

To me it appears the server sends back an OK response to me but for some reason the onReceive function cannot parse the data. Am I doing anything wrong?