title: How to make a JSONArray Request with post param using volley in Android
body: <p>This is the method for getting the groups:</p>
  
  <pre><code>public void getGroupsThree() {
          String tag_json_obj = "json_obj_obj"; /* tag used to cancel the request */
          String loginUrl = "removed for security reasons"; /* login rest url */
  
          /* show the progress bar */
          PD = new ProgressDialog(getActivity());
          PD.setMessage("Loading...");
          PD.show();
  
          /* this are the params to post */
          Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
          params.put("userID", "13");
          params.put("secretKey", "andrew");
          params.put("starts", "5");
          params.put("limits", "10");
  
          CustomRequestJsonArray jsonArr;
          jsonArr = new CustomRequestJsonArray(Request.Method.POST, loginUrl, null,
                  new Response.Listener&lt;JSONArray&gt;() {
                      @Override
                      public void onResponse(JSONArray response) {
  
                          for(int i = 0; i &lt; response.length(); i++) {
                              try {
                                  JSONObject groupData = (JSONObject) response.get(i);
                                  Toast.makeText(getActivity(), "Response: " + groupData.getString("groupID"), Toast.LENGTH_LONG).show();
                              } catch (JSONException e) {
                                  Toast.makeText(getActivity(), "Json Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
                              }
  
                          }
                          PD.hide();
                      }
                  }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  /* handle request error */
                  Toast.makeText(getActivity(), "Response " + error.getMessage(), Toast.LENGTH_LONG).show();
                  PD.hide();
              }
          }, params);
  
          /* add the request to the request queue */
          VolleyApplication.getInstance().addToRequestQueue(jsonArr, tag_json_obj);
  
      }
  </code></pre>
  
  <p>Here is my CustomRequestJsonArray class</p>
  
  <pre><code>public class CustomRequestJsonArray extends JsonRequest&lt;JSONArray&gt; {
  
  
      private Response.Listener&lt;JSONArray&gt; listener;
      private Map&lt;String, String&gt; params;
  
      public CustomRequestJsonArray(int method, String url, String requestBody,
                                    Response.Listener&lt;JSONArray&gt; listener, Response.ErrorListener errorListener,Map&lt;String, String&gt; params) {
          super(method, url, requestBody, listener,
                  errorListener);
          this.params = params;
      }
  
      @Override
      protected Map&lt;String, String&gt; getParams() throws com.android.volley.AuthFailureError {
          return params;
      };
  
      @Override
      protected void deliverResponse(JSONArray response) {
          listener.onResponse(response);
      }
  
      @Override
      protected Response&lt;JSONArray&gt; parseNetworkResponse(NetworkResponse response) {
          try {
              String jsonString = new String(response.data,
                      HttpHeaderParser.parseCharset(response.headers));
              return Response.success(new JSONArray(jsonString),
                      HttpHeaderParser.parseCacheHeaders(response));
          } catch (UnsupportedEncodingException e) {
              return Response.error(new ParseError(e));
          } catch (JSONException je) {
              return Response.error(new ParseError(je));
          }
      }
  
  
  
  }
  </code></pre>
  
  <p>Response Error is</p>
  
  <blockquote>
    <p>"JSONObject cannot be converted to JSONArray"</p>
  </blockquote>
  
  <p>I think the params are not being posted. This is want am expecting:</p>
  
  <pre><code>[
    {
      "groupID": "28",
      "userID": "13",
      "name": "ACS Test Edit",
      "description": "Edited by Joe",
      "createdOn": "2015-09-29 08:55:49",
      "active": "1"
    },
    {
      "groupID": "25",
      "userID": "13",
      "name": "ICT consulting",
      "description": "",
      "createdOn": "2015-09-28 07:32:33",
      "active": "1"
    }
  ]
  </code></pre>
  
  <p>In case of any Error, like invalid security key or missing parameters, I should get this:</p>
  
  <pre><code>{
    "code": "404",
    "error": "You are not permitted to access this resource"
  }
  </code></pre>
  
  <p>When I run the app, this is what am getting:</p>
  
  <blockquote>
    <p>Caused by: org.json.JSONException: Value {"error":"You are not permitted to access this resource","code":"404"} of type org.json.JSONObject cannot be converted to JSONArray</p>
  </blockquote>
  
  <p>So, I this the parameters are not being posted. How do I make sure they are posted?</p>