I wanted to invoke a Simple WCF Service that is hosted in my local using SP.WebRequestInfo class in my SharePoint Hosted app. I was able to get it working without an parameter but as soon as I add set_body I get an error. 400-Bad Request. This call works super good in plain jQuery. I am guessing it is because of body format I am passing. I had tried all sort of formats to pass the value no luck. Please help.
function getVal()
{
"use strict";
var context = SP.ClientContext.get_current();
var request = new SP.WebRequestInfo();
request.set_url( "http://oops/EatAndSplit.svc/Split2" );
request.set_method("POST");
// We need the response formatted as JSON.
request.set_headers({ "Accept": "application/json; charset=utf-8" });
request.set_body(JSON.stringify({ data: { "x": "1" } }));
response = SP.WebProxy.invoke(context, request);
context.executeQueryAsync(successHandler, errorHandler);
}