Skip to content

Instantly share code, notes, and snippets.

@narath
Created May 8, 2017 17:24
Show Gist options
  • Select an option

  • Save narath/9e74cb7dd17050c76936fded2861f2d1 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

thanks 👍

@fhyfirman

Copy link
Copy Markdown

Thanks,
You save my time

@Fedcomp

Fedcomp commented Feb 6, 2025

Copy link
Copy Markdown

Surprised it's not in the docs.

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