I am trying to upload file with'rest-client' gems.
回答済みI am trying to upload file with'rest-client' gems. I have tried but no luck. Here the code I tried so far.
content_type = MIME::Types.type_for('/home/vagrant/mukesh.txt').first.content_type headers = { "Authorization"=> "Bearer ", "Content-Type"=> content_type } payload = { "attributes"=> {"name"=>"mukesh.txt", "parent"=>{"id"=>"0"}}, "file"=> File.new('/home/vagrant/mukesh.txt', 'rb'), "multipart"=> true } response = RestClient::Request.execute(:method=> :post,:url=>"https://upload.box.com/api/2.0/files/content",:payload=>payload , :headers=> headers)
It is giving, 405 method not allowed errors. Can somebody help me?
-
Have you seen the Box Ruby SDK? Here is the method signature to upload a file with the Ruby SDK.
-
I won't able to upload a file from rest-client. Surprising, It does work with the postman, though postman externally using rest call only. I think something wrong with the code that I have written.
Using Boxer (Ruby gem) easy and fast. It does solve my problem so I completed my task with boxr gem.
サインインしてコメントを残してください。
コメント
5件のコメント