How do you do a Remote HTTP Post (request) in ruby?
+5
A:
With Net::HTTP. Correct but non-working example (because Google only supports GET — sorry, I couldn't think of any open POST forms off the top of my head):
require 'net/http'
require 'uri'
result = Net::HTTP.post_form(URI.parse("http://google.com/search"), {"q" => "Rick Astley"})
Chuck
2009-02-12 18:47:42
You are posting a form to a search which takes get parameters. Google will return you an error.
Mike Leffard
2009-02-13 16:55:48
That's what I said. Google actually requires GET parameters, but I couldn't think of any good examples of commonly used POST forms off the top of my head. I think it pretty clearly illustrates how you do a POST, though.
Chuck
2009-02-14 02:38:27
A:
If the server conforms to REST you should take a look at either rest-client or ActiveResource.
Antti Tarvainen
2009-02-13 13:03:39