The Error received
In a general way, the error Error parsing data org.json.JSONException ...
refers to the inability to process JSON.
For your particular case, it can be read in the error message:
Error Parsing data org.json.Jsonexception: Value of type java.lang.String cannot be converted to Jsonobject
That translated:
Error processing data org.json.Jsonexception: Value of type java.lang.String cannot be converted to Jsonobject
That tells us that a string
instead of an object, as would be expected.
Deal with the mistake
One way to deal with the error in scenarios like this is to wrap your code in one try...catch
so as to try work the data received while able to catch any errors in a way that allows you to deal with them:
try {
JSONObject jobj = new JSONObject(response);
String succes = jobj.getString("success");
...
} catch (JSONException e) {
// ups, correu mal... vamos ver o que aconteceu
e.printStackTrace();
}
It would be good to test the returned content. There may have been an exception and the apache error page is being returned, for example. Can you simulate the call from a browser or in some other way?
– utluiz
Surely some exception is being returned... Kick error 500 or 404
– Tiago César Oliveira
That’s right, apache is sending an error page instead of JSON. Thank you!
– user3174