Hi all, I'm switching my Dropbox app from oauth1 to oauth2. I've an issue when I try to download a file.
I use this code:
var r = Call("https://content.dropboxapi.com/2/files/download", access_token, "{\"path\":\"" + metaPath + "\"}");
private string Call(string endpoint, string access_token, string json) {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Bearer " + access_token);
request.Method = "POST";
Stream requestStream = request.GetRequestStream();
requestStream.Write(Encoding.UTF8.GetBytes(json), 0, json.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string txtResponse = reader.ReadToEnd();
return txtResponse;
}
The "Call" function works well whit *list_folder* endpoint. But I get a 400 http error (invalid request) with *download* endopint. Any tips? It's the right way?
Thanks!