I'm trying to get the contents of a folder for downloading from Dropbox in C# using the HTTP libraries. So far I've been trying to use a console application project in Visual Studio but don't seem to be making alot of headway.
What I would like to do is A) See if there are files in the folders and then
download then to a location (in this case a SharePoint library but I can't seem to make the initial connection using .Net 3.5
Code sample so far:
static void Main(string[] args)
{
using (WebClient client = new WebClient())
{
var URI = new Uri("https://api.dropboxapi.com/2/files/list_folder");
client.Headers.Set("Content-Type", "application/json");
client.Headers.Add("Authorization", "Bearer <MyApplicationAccessToken>");
// data
var reqparm = new System.Collections.Specialized.NameValueCollection();
reqparm.Add("path", "/<MyApplicationFolder>/");
reqparm.Add("recursive", "false");
reqparm.Add("include_media_info", "false");
reqparm.Add("include_deleted", "false");
reqparm.Add("include_has_explicit_shared_members", "false");
reqparm.Add("include_mounted_folders", "true");
byte[] reqBytes = Encoding.ASCII.GetBytes(reqparm.ToString());
byte[] responsebytes = client.UploadData(URI, "POST", reqBytes);
string responsebody = Encoding.UTF8.GetString(responsebytes);
}
}
Any ideas? Cant use the .Net SDK