How to get String response from JSONObject in Volley
You can use StringRequest instead JSONRequest.
StringRequest stringRequest = new StringRequest(methodType, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return headers == null ? super.getHeaders() : headers;
}
@Override
public byte[] getBody() throws AuthFailureError {
return "Your JSON body".toString().getBytes();
}
};
getheaders
method is to add custom headers if you want and getBody
to supply request body
.