Hello,
I am trying to read Json response on specific HTTP status code using volley error method. Yet I am unable to read JSON response following this way it gives me HTML code while returning the response.
//Doing this by Using VolleyError class.
String responseBody = new String(error.networkResponse.data, “utf-8”);
// Log.i(“DataX:”, responseBody);
// JSONObject data = new JSONObject(responseBody);
// Log.i(“Data:”, error.networkResponse.data.toString());
If anyone can provide any help with this.
This may be related.
frappe:develop
← gavindsouza:response-type-json
opened 05:58AM - 29 Apr 21 UTC
**Before**
If header `'Accept: application/json'` isn't set, the failure resp… onses to `/api/` endpoints are HTML. Success responses are of type JSON.


**After**
If the header `Accept` isn't set, the failure responses to `/api/` endpoints are of type JSON. Success responses are of type JSON as well. To receive responses in HTML, you can set the header `'Accept: text/html'`, though any `text/` mime type will only return an HTML response at this point.


If your ERPNext server is not upgraded to include the code in PR, then use “Accept” header like mentioned in PR and try
@revant_one Thank you so much for your input on this. Yes, It was because of the headers. I am able to fetch the JSON with other status code as well.