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'
.
I would expect it to work without the second instantiation as it would be the first request-objects or the http-object's job but it worked for me this way.
or
Might not be perfect but at least you get the idea.
Use Excon:
new to stack overflow and I guess I can't comment, but @chris.moose is missing double quotes in his function def. line 5 should be:
or here's the whole thing redefined for copy/pasting
<3 -mike
Use the following method: