Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Net::HTTP.post

post(url, data, header = nil)

Posts data to the specified URI object.

Example:

Example
require 'net/http'
require 'uri'

Net::HTTP.post URI('http://www.example.com/api/search'),
               { "q" => "ruby", "max" => "50" }.to_json,
               "Content-Type" => "application/json"
See also #post .new .post_form .https_default_port also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1