Android Volley edit

Use JSONArray as request body

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
64 Menu
71 Volley
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close