I'm trying to convert some code from HTTParty
to Faraday
. Previously I was using:
HTTParty.post("http://localhost/widgets.json", body: { name: "Widget" })
The new snippet is:
faraday = Faraday.new(url: "http://localhost") do |config|
config.adapter Faraday.default_adapter
config.request :json
config.response :json
end
faraday.post("/widgets.json", { name: "Widget" })
Which results in: NoMethodError: undefined method 'bytesize' for {}:Hash
. Is it possible to have Faraday automatically serialize my request body into a string?