Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Net::HTTPGenericRequest#body=
body=(str)
lib/net/http/generic_request.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/net/http/generic_request.rb, line 154
def body=(str)
@body = str
@body_stream = nil
@body_data = nil
str
end
Sets the body for the request:
Example
req = Net::HTTP::Post.new(uri) req.body # => nil req.body = '{"title": "foo","body": "bar","userId": 1}' req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}"