Skip to content

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

class · Ruby 3.2

Net::HTTP::Post

Class for representing HTTP method POST:

Example
require 'net/http'
uri = URI('http://example.com')
hostname = uri.hostname # => "example.com"
uri.path = '/posts'
req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
req.body = '{"title": "foo","body": "bar","userId": 1}'
req.content_type = 'application/json'
res = Net::HTTP.start(hostname) do |http|
  http.request(req)
end

Properties:

Related:

Constants
No documentation available
No documentation available
No documentation available