I’m using the apache http library and need to know how to add a parameter to an HTTP GET request. I’ve looked over How to add parameters to a HTTP GET request in Android? but the accepted answer for that adds parameters to an HTTP POST. This is my code so far but it is not working.
HttpGet get = new HttpGet("https://server.com/stuff");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("count", "5"));
HttpParams p = get.getParams();
p.setParameter("length", "5");
get.setParams(p);
unlike POST, GET sends the parameters under the url like this:
Where: the parameters area start from the question mark and on so the variable1 is the first param and it has “value” value…
See here for more informations.
So what you need to do is just build an url that contains also these parameters according to server needs.
EDIT:
In your case :
Where: count=5 and length=5 are the parameters and the “?” mark is the beginning of the parameters definition…
I hope that helps.