-
-
Save drbrain/76c9833c7f88f623a70f to your computer and use it in GitHub Desktop.
POST example from Net::HTTP documentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uri = URI('http://www.example.com/todo.cgi') | |
req = Net::HTTP::Post.new(uri) | |
req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31') | |
res = Net::HTTP.start(uri.hostname, uri.port) do |http| | |
http.request(req) | |
end | |
case res | |
when Net::HTTPSuccess, Net::HTTPRedirection | |
# OK | |
else | |
res.value | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment