Showing 400 bad request when try to post file via rest API with Ruby -
i'm try post file using restclient
ruby on rails, have try conver below curl
command:
curl -h 'authorization: bearer access_token' -f 'file=@file_path' https://api.com/api
when converting restclient
below:
res = restclient::request.new( method: :post, url: 'https://api.com/api', :payload => { :file => file.new("#{rails.root}/public/sample.docx" , 'rb') }, :headers => { :authorization => "bearer 155c5e5c4feea51b386fdfe204abc60b7f4025fb91988519de869525217b4702", :content_type => "multipart/form-data" } ) res.execute
on code showing 400 bad request
what i'm doing wrong code?
thanks
your post duplicate of 1 ruby - uploading file using restclient post
in case, try changing content_type application/vnd.openxmlformats-officedocument.wordprocessingml.document
list of mime types can found here: what correct mime type docx, pptx etc?
Comments
Post a Comment