1

I am doing an Api automation in Ruby and I am using the Gem Faraday to automate a file upload in my API.

I have the follow problem:

My Header is not being sent. I just tried all the options and is not working at all.

Heres the last syntaxe that I am using:

conn = Faraday.new($api['upload']) do |f|
  f.request :multipart
  f.adapter Faraday.default_adapter
end 

payload = { :file => Faraday::UploadIO.new('./arquivo/pequeno.pdf', 'file/pdf') }
headers = {'Content-Type' => 'multipart/form-data', 'Authorization' => 'Bearer ' + @token, 'uuidUser' => @uuid}

conn.post('/upload', payload, headers)

Also, I cannot get the response body or code. I got the error that method body or code or status does not exist.

Do you have any idea what I may be doing wrong?

Thanks ;)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.