I am trying to send a message in api. This example from the docs works in curl:
curl -k -w %{http_code} -H "Content-Type:text/plain" -u user:pass --data-binary @filename https:
This is what I tried with faraday:
require 'rubygems'
require 'faraday'
require 'pp'
conn = Faraday.new(:url => 'https://server/url/here' , :ssl => {:verify => false} ) do |faraday|
faraday.response :logger
faraday.basic_auth('user', 'pass')
faraday.adapter Faraday.default_adapter
end
data = File.read('teste.txt')
res=conn.post '/' , data
pp res
Posts, I get code 200, but something is wrong. The answer is the server login page.
Is curl -u equivalent to basic auth?
source
share