How do you do a Remote HTTP Post (request) in ruby?
From stackoverflow
-
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"})Mike Leffard : You are posting a form to a search which takes get parameters. Google will return you an error.Chuck : 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. -
If the server conforms to REST you should take a look at either rest-client or ActiveResource.
0 comments:
Post a Comment