I'm trying to use okhttp to build a post request to send JSON to an existing service. but when ever i try to send the form okhttp escapes all the special characters in the JSON - but the server is coded to only accept it not-escaped.
String msg = "{SomeJsonMsg:...}";
FormEncodingBuilder b = new FormEncodingBuilder();
b.addEncoded( msg, "" );
RequestBody form_body = b.build();
Using wireshark it shows the following for the app im trying to re-code (ie a GOOD call):
D=E@d+2JPe NGnPPOST /pp/httpService.do HTTP/1.1
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.2; GT-I9500 Build/KOT49H)
Host: test.com
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Type: application/x-www-form-urlencoded
Content-Length: 213
{"callPara": {"userPassword":"password!","userName":"myname","gameName":"SGZJ-ANDROID-SG","udid":"d5d96bcc3a8e436ab991d35eb284d6bd","clientType":"EN","releaseChannel":"EN","locale":"EN"},"serviceName":"login"}
but the java code above dumps this (a BAD call):
D=Ev@+2J,P ^FPPOST /pp/httpService.do HTTP/1.1
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.2; GT-I9500 Build/KOT49H
Content-Type: application/x-www-form-urlencoded
Content-Length: 324
Host: test.com
Connection: Keep-Alive
Accept-Encoding: gzip
%7B%22callPara%22%3A%7B%22userPassword%22%3A%22password%21%22%2C%22userName%22%3A%22myname%22%2C%22gameName%22%3A%22SGZJ-ANDROID-SG%22%2C%22udid%22%3A%226d49ee067762822c6a8f721d256ce44c%22%2C%22clientType%22%3A%22EN%22%2C%22releaseChannel%22%3A%22EN%22%2C%22locale%22%3A%22EN%22%7D%2C%22serviceName%22%3A%22login%22%7D=
Is there anyway to do this using okhttp? i have tried b.add( msg, "" ) and b.addEncoded( msg, "" ) - cannot really tell a difference between the two, nor does the java doc say anything about the two calls.