0
votes

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

1 Answers

0
votes

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.