Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a POST request with open-uri?

Tags:

ruby

open-uri

Is it possible to make a POST request from Ruby with open-uri?

like image 995
Alexey Lebedev Avatar asked Oct 28 '08 08:10

Alexey Lebedev


People also ask

What is Open Uri?

OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.

How do you create a post request in Ruby?

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.


1 Answers

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.

like image 94
Martin Kenny Avatar answered Oct 02 '22 18:10

Martin Kenny