N
ngw
Hi everyone, I'm trying to use faraday (with default adapter) to put some binary-data to an url.
The request I'm trying to do using curl is:
curl -X PUT https://your_user_token:@api.80legs.com/v2/urllists/name_of_url_list -H "Content-Type: application/octet-stream" --data-binary "[\"http://www.example.com/\", \"http://www.sample.com/\", \"http://www.test.com/\"]" -i
In Faraday I'm setting up the request probably in the wrong way:
require 'tempfile'
tempfile = Tempfile.new(name)
tempfile.write url_list.to_s
conn = Faraday.new(url: "https://#{token}api.80legs.com/v2/urllists/#{name}") do |faraday|
faraday.request :multipart
faraday.response :logger
end
conn.put do |req|
req.headers['Content-Type'] = 'octet/stream'
req.body = Faraday::UploadIO.new(tempfile, 'octet/stream')
end
tempfile.close
Has someone managed to do something like this before with this gem?
ngw
The request I'm trying to do using curl is:
curl -X PUT https://your_user_token:@api.80legs.com/v2/urllists/name_of_url_list -H "Content-Type: application/octet-stream" --data-binary "[\"http://www.example.com/\", \"http://www.sample.com/\", \"http://www.test.com/\"]" -i
In Faraday I'm setting up the request probably in the wrong way:
require 'tempfile'
tempfile = Tempfile.new(name)
tempfile.write url_list.to_s
conn = Faraday.new(url: "https://#{token}api.80legs.com/v2/urllists/#{name}") do |faraday|
faraday.request :multipart
faraday.response :logger
end
conn.put do |req|
req.headers['Content-Type'] = 'octet/stream'
req.body = Faraday::UploadIO.new(tempfile, 'octet/stream')
end
tempfile.close
Has someone managed to do something like this before with this gem?
ngw