There was an error while loading. Please reload this page.
Use the :params option to add query string parameters to requests:
:params
HTTP.get("http://example.com/resource", :params => {:foo => "bar"})
Use the :form option to pass data serialized as form encoded:
:form
HTTP.post("http://example.com/resource", :form => {:foo => "42"})
The :body option allows posting a raw request body:
:body
HTTP.post("http://example.com/resource", :body => "foo=42&bar=baz")
Request bodies can be String, Enumerable or IO-like object. Enumerable and IO-like objects can be used for streaming request bodies.
String
Enumerable
The :json option allows serializing Ruby objects as JSON:
:json
HTTP.post("http://example.com/resource", :json => { :foo => "42" })
To upload files in multipart format, construct the form as follows:
HTTP.post("http://example.com/resource", :form => { :username => "ixti", :avatar => HTTP::FormData::File.new("/home/ixit/avatar.png") })
To upload files in raw format, pass the file as the request body:
HTTP.post("http://example.com/resource", body: File.open("/home/ixit/avatar.png"))