(Android) Seems like my JSON query is getting double encode
Posted
by
A Gardner
on Stack Overflow
See other posts from Stack Overflow
or by A Gardner
Published on 2011-01-14T05:27:56Z
Indexed on
2011/01/14
6:53 UTC
Read the original article
Hit count: 207
Hi,
I am getting some weird errors with my Android App. It appears that this code is double encoding the JSON string. What should be sent is ?{"email":"[email protected]","password":"asdf"} or ?%7B%22email%22:%22.....
what the server is seeing is %257B%2522email%2522:%2522 .... which means the server sees %7B%22email%22:%22 .....
This confuses the server.
Any ideas why this is happening?
Thanks for your help
Code:
DefaultHttpClient c = new DefaultHttpClient();
if(cookies!=null)
c.setCookieStore(cookies);
if(loginNotLogout){
jso.put("email", userData.email);
jso.put("password", userData.password);
}
URI u = null;
if(loginNotLogout)
u= new URI("HTTP","www.website.com","/UserService",jso.toString(),"");
else
u= new URI("HTTP","www.website.com","/UserService",jso.toString(),"");
HttpGet httpget = new HttpGet(u);
HttpResponse response = c.execute(httpget);
ret.jsonString = EntityUtils.toString(response.getEntity());
© Stack Overflow or respective owner