4

I am using the volley library for making a post request to the server. This library uses Map<String, String> for the post parameters. My problem is want to have multiple values for the same key, which can be using NameValuePairs but it cannot be used with volley. Thanks in advance!

nihartrivedi810
  • 333
  • 1
  • 2
  • 12

1 Answers1

0

try override below method, it is from source code:

/**
 * Returns the raw POST or PUT body to be sent.
 *
 * @throws AuthFailureError in the event of auth failure
 */
public byte[] getBody() throws AuthFailureError {
    Map<String, String> params = getParams();
    if (params != null && params.size() > 0) {
        return encodeParameters(params, getParamsEncoding());
    }
    return null;
}

Returns the raw POST or PUT body to be sent.

so override the getBody() with your parameter.

mmlooloo
  • 18,937
  • 5
  • 45
  • 64
  • So, how will it help me to have entries with duplicate keys? Can you please elaborate a bit? – nihartrivedi810 Dec 24 '14 at 18:30
  • override `getBody()` construct your `NameValuePairs` then convert it to `byte array`, or construct something like `"key=value1&key=value2"` then convert it to byte array. – mmlooloo Dec 24 '14 at 18:33