Can someone point me to an example of sending a POST request using Net::HTTP?
I found one at http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html,
but this use the method post_data which, when I look at the source in
http.rb, is not a method of Net::HTTP. Maybe it's outdated
documentation.
This is what I've tried. I suspect I'm not passing the form data
correctly. The response is a Net::HTTPBadRequest.
---
require 'net/http'
host = 'www.runningbuzz.com'
Net::HTTP.start(host) do |http|
data = {
'CalcWhat' => '2',
'timeH' => '2',
'timeM' => '57',
'timeS' => '17',
'distance' => '26.2',
'optDist' => 'miles',
'optPace' => 'miles'
}
response = http.post('pace_calculator.htm', data)
puts response.body
end
--
R. Mark Volkmann
Partner, Object Computing, Inc.