Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Net::HTTPGenericRequest#body=

body=(str)

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}"
See also #body_stream= #encode_multipart_form_data also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0