Skip to content

Instantly share code, notes, and snippets.

@narath
Created May 8, 2017 17:24
Show Gist options
  • Save narath/9e74cb7dd17050c76936fded2861f2d1 to your computer and use it in GitHub Desktop.
Save narath/9e74cb7dd17050c76936fded2861f2d1 to your computer and use it in GitHub Desktop.
How to do a x-www-form-urlencoded post with Faraday
require 'faraday'
require 'uri'
data = {
:your_data => "YOUR DATA"
}
url = "some url"
response = Faraday.post(url) do |req|
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = URI.encode_www_form(data)
end
puts response.inspect
@Navinnair
Copy link

thanks 👍

@fhyfirman
Copy link

Thanks,
You save my time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment