Use JSONArray as request body

suggest change

The default requests integrated in volley don’t allow to pass a JSONArray as request body in a POST request. Instead, you can only pass a JSON object as a parameter.

However, instead of passing a JSON object as a parameter to the request constructor, you need to override the getBody() method of the Request.class. You should pass null as third parameter as well:

JSONArray requestBody = new JSONArray();

new JsonObjectRequest(Request.Method.POST, REQUEST_URL, null, RESP_LISTENER, ERR_LISTENER) {
    public byte[] getBody() {
        try {
            return requestBody.toString().getBytes(PROTOCOL_CHARSET);
        } catch (UnsupportedEncodingException uee) {
            // error handling
            return null;

Explanation of the parameters:

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents