將文件上傳到保管箱時,方法出錯 (while uploading a file to dropbox getting an error with method)


問題描述

將文件上傳到保管箱時,方法出錯 (while uploading a file to dropbox getting an error with method)

Am using below url to upload a file to dropbox using oauth and am getting an error  {"error": "Call requires one of the following methods: PUT, POST, got GET!"} am passing httpmethod as PUT but still asking the error.

Signature am using to upload is 

https://api‑content.dropbox.com/1/files_put/dropbox/test?oauth_consumer_key=twcek2m7cxtantc&oauth_signature_method=PLAINTEXT&oauth_token=918v4lxg2w23car&oauth_version=1.0&oauth_signature=fbs34nykryouuj1%26rbbprgh95tjzf22

using this am getting the error 

{"error": "Call requires one of the following methods: PUT, POST, got GET!"}

please tell me anyone what to do for resolve this error.

public FileSystemInfo UploadFile(string root, string path, string file)
        {
            var uri = new Uri(new Uri(DropboxRestApi.ApiContentServer),
                String.Format("files_put/{0}/{1}",
                root, UpperCaseUrlEncode(path)));

            var oauth = new OAuth();
            //var requestUri = oauth.DownloadSignRequest(uri, _consumerKey, _consumerSecret, "POST", _accessToken);
            var requestUri = oauth.SignRequest(uri, _consumerKey, _consumerSecret, _accessToken, "PUT");

            var request = (HttpWebRequest) WebRequest.Create(requestUri);
            request.Method = WebRequestMethods.Http.Post;
            request.KeepAlive = true;

            byte[] buffer;
            using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
            {
                int length = (int) fileStream.Length;
                buffer = new byte[length];
                fileStream.Read(buffer, 0, length);
            }

            request.ContentLength = buffer.Length;
            using (var requestStream = request.GetRequestStream())
            {
                requestStream.Write(buffer, 0, buffer.Length);
            }

           // request.Method = "POST";

            var response = request.GetResponse();
            var reader = new StreamReader(response.GetResponseStream());
            var json = reader.ReadToEnd();
            return ParseJson<FileSystemInfo>(json);
        }

‑‑‑‑‑

參考解法

方法 1:

I made a mistaken in saving path of the file where i want to upload it.

Give the same file name for save in path.

that's all.

(by user1969032user1969032)

參考文件

  1. while uploading a file to dropbox getting an error with method (CC BY‑SA 3.0/4.0)

#dropbox #file-upload #OAuth






相關問題

獲取 Dropbox 共享鏈接的文件列表 (Get list of files for dropbox shared link)

將文件上傳到保管箱時,方法出錯 (while uploading a file to dropbox getting an error with method)

Dropbox Api putFile php 發送文件失敗 (Dropbox Api putFile php fail send file)

Tiếp tục quá trình tải lên trong IOS nền (Continue uploading process in background IOS)

API Dropbox: phát hiện cập nhật tệp và nhận URL đến tệp? (Dropbox API: detect file updates, and get a URL to a file?)

Mac OS X 文件的 st_flags(用戶定義的標誌)是什麼? (What are st_flags (user defined flags) for a file Mac OS X?)

Dropbox如何監控? (How does dropbox monitoring?)

如何在 Dropbox 中使用 Bazaar? (How to use Bazaar with Dropbox?)

在 Python 中使用 OAuth2 連接到保管箱時出錯 (Error using OAuth2 to connect to dropbox in Python)

從樹莓派自動上傳到保管箱? (automatic upload on dropbox from raspberry pi?)

識別 macOS 上的託管文件夾 (Identify managed folders on macOS)

我們如何在下載/上傳 dropbbox 方法中獲取文件 mime-type/content-type? (How can we get files mime-type/content-type in download/upload dropbbox methods?)







留言討論