Python and urllib2: how to make a GET request with parameters
- by Infinity
I'm building an "API API", it basically a wrapper for a in house REST web service that the web app will be making a lot of requests to.
Some of the web service calls need to be GET rather than post, but passing parameters.
Is there a "best practice" way to encode a dictionary into a query string? e.g.: ?foo=bar&bla=blah
I'm looking at the urllib2 docs, and it looks like it decides by itself wether to use POST or GET based on if you pass params or not, but maybe someone knows how to make it transform the params dictionary into a GET request.
Maybe there's a package for something like this out there? It would be great if it supported keep-alive, as the web server will be constantly requesting things from the REST service.
Thanks!