Send POST request to external server

How can I send a post request to an external server from my app
controller?
I tried with this but didn’t work:
require “uri”
require “net/http”
params = {“box1” => “Nothing is less important than which fork you use.
Etiquette is the science of living. It embraces everything. It is
ethics. It
is honor. -Emily Post”,
“button1” => “Submit”}
x = Net::HTTP.post_form(URI.parse(“http://localhost:3000”),params)
puts x.body
Thanks in advance!

Douglas,

I dont know what error occurs, but how’bout this code?

require “uri”
require “net/http”

params = {“box1” => “Nothing is less important than which fork you
use.
Etiquette is the science of living. It embraces everything. It is
ethics. It
is honor. -Emily Post”, “button1” => “Submit”}

Net::HTTP.start(‘http://localhost:3000’, 80) {|http|
response = http.post(’/’, params)
puts response.body
}

Hope this would work well.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs