Passing parameters to volley request


Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster. But as being new its quiet confusing for most of us.

One of the confusion is setting parameters in volley requests. The paramenters can be set in a volley request by overriding getParams() method of Request<T> class. But the problem is that the getParams() is called only in the case of POST or PUT request. As the documentation says:

But what in case of GET method!!

In case of GET method the paraments are concatenated with the url and then url is passed.

Its quiet easier approach but it becomes a lot of work when you have a lot of parameters then you have to concatenate each and every paramenter in the url. In GET request the getParams() is not even called so there is no way you can use the methods

In case of POST method you can override the getParams() and give all the parameters you want over there.

Also for JSONobjectRequest the getParams() doen’t even work for POST request so you have to make a customRequest and override getParams() method over there. Its because JsonObjectRequest is extended JsonRequest which override getBody() method directly, so your getParam() would never invoke. To invoke your getParams() method you first have to override getBody(). Or for a simple solution you can use StringRequest.


. . .

Leave a comment

1 Comment


It was a successful collaboration. The Mobikul team provided the client everything they needed in a timely and high-quality manner. They were very professional, reliable, and accessible during the entire process. The client also saw no room for any improvements in the vendor's performance.

Vincenzo Carrano

Vincenzo Carrano

Administrator, Segshop

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home