How do I make an HTTP GET
request with parameters in Ruby?
It's easy to do when you're POST
ing:
require 'net/http'
require 'uri'
HTTP.post_form URI.parse('http://www.example.com/search.cgi'),
{ "q" => "ruby", "max" => "50" }
But I see no way of passing GET
parameters as a hash using 'net/http'
.
Since version 1.9.2 (I think) you can actually pass the parameters as a hash to the URI::encode_www_form method like this:
and then fetch the result, depending on your preference
or