Skip to content

Instantly share code, notes, and snippets.

@tbreier
Created March 24, 2015 00:18
Show Gist options
  • Select an option

  • Save tbreier/ee35b59e598d44535452 to your computer and use it in GitHub Desktop.

Select an option

Save tbreier/ee35b59e598d44535452 to your computer and use it in GitHub Desktop.
Faraday Encoding
require 'faraday'
connection = Faraday.new do |c|
c.response :logger
c.adapter Faraday.default_adapter
end
connection.token_auth 'my_token'
connection.post do |request|
request.url 'http://www.posttestserver.com/' # returns 200 Success when I use my Rails server
request.body = "From: \"Me\" <[email protected]>\nTo: \"You\" <[email protected]>\nHello"
end
puts "----------------------------------------------"
connection.post do |request|
request.url 'http://www.posttestserver.com/' # returns 400 Bad Request when I use my Rails server
request.body = "From: \"Me\" <[email protected]>\nTo: \"You\" <[email protected]>\nHello %%"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment