Skip to content

Instantly share code, notes, and snippets.

@tbreier
Created March 24, 2015 00:18
Show Gist options
  • Save tbreier/ee35b59e598d44535452 to your computer and use it in GitHub Desktop.
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\" <info@info.com>\nTo: \"You\" <info@info.com>\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\" <info@info.com>\nTo: \"You\" <info@info.com>\nHello %%"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment