I am getting the following error from a webapi call in an Android app using volley:
org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
And I want to know how to see the exact message from the server as opposed to the Volley error. Here is the code:
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d(TAG, "onResponse: " + response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (error instanceof ParseError) {
Log.d(TAG, "onErrorResponse: ParseError: ");
}
}
});
queue.add(request);
It is a really basic call and under most circumstances I get back the jsonobject, but in those cases where the server sends me something different I want to be able to account for it. The error which is thrown is parsing of a value which is not json because it is an error. How can I see what the server is sending from the ErrorListener?