Is it possible to make a POST request from Ruby with open-uri?
OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
POST request For this request we use the post_form method of Net::HTTP , and after the uri we give our params in the key value form. Then we print the response body if the request was a success. Of course do not hesitate to dive in the docs, and here is a cheat sheet for quick reference.
Unfortunately open-uri
only supports the GET
verb.
You can either drop down a level and use net/http
, or use rest-open-uri
, which was designed to support POST
and other verbs. You can do gem install rest-open-uri
to install it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With