0

I've read all two pages of existing questions about DropNet and I still can not understand why I can not upload a file from a folder on my PC to my dropbox using DropNet library and C# in a desktop application. This is my code that executes on a button click:

 private void ExportToDropbox(object sender, RoutedEventArgs e)
    {
        var client = new DropNetClient("<REDACTED>", "<REDACTED>");
        client.UserLogin = new UserLogin();


        var fileBytes = File.ReadAllBytes(@"../../Reports/Donka-Karamanova-dk-Report.docx");
        var uploadResult = client.UploadFile("/", "Donka-Karamanova-dk-Report_copy.docx", fileBytes);
    }
ttitto
  • 97
  • 1
  • 10

2 Answers2

1

You didn't say what error you're getting or when, but your UploadFile call looks suspicious.

I imagine that the first parameter is supposed to be the path you're uploading to in Dropbox. So "/" would upload to the root of Dropbox (or the root of your app's app folder). The path "../../" doesn't make sense.

user94559
  • 59,196
  • 6
  • 103
  • 103
  • I do not receive any error. The app just doesn't copy the file. While debugging I see that the filebytes are correctly read and the filebytes array is full. But After running I can not find the docx file in my dropbox. – ttitto Oct 03 '14 at 17:26
  • The result was exactly the same when I tried the code with first argument "/" – ttitto Oct 03 '14 at 17:29
  • How sure are you that you're looking in the right account in the right location? It could be that DropNet is swallowing some error here, but it's also possible the code is, in fact, succeeding. If you can run this through a proxy (like Fiddler), it might be easier to see what's happening. – user94559 Oct 03 '14 at 18:28
  • Is this the info from the fiddler that you need: https://www.dropbox.com/s/08fmyykxm4i3n2c/RawDataFiddler.txt?dl=0 – ttitto Oct 03 '14 at 19:05
  • It would be easier to tell from the *response* to this HTTP request, but it looks like you're making an unauthenticated call (no token and secret for a user). You'll need to follow DropNet's instructions for how to authenticate a user and get an OAuth token. – user94559 Oct 03 '14 at 19:42
  • Also, I should not that your Fiddler trace once again exposed your app key and secret. I'd really recommend creating a new app. – user94559 Oct 03 '14 at 19:43
1

As smarx mentioned in his comments it looks like the problem seems to be the user is not Authenticated with your dropbox app.

Also this line:client.UserLogin = new UserLogin(); won't actually do anything without giving it an access token and secret. That you should be getting from your authentication process.

There is also an issue with the library where it fails without Exception or response if you are using it with an API key meant for an App folder usage instead of root folder access. See this link for details: https://github.com/DropNet/DropNet/issues/75

If you are trying to use it with App folder access you will need to set the client.UseSandbox = true flag on your client instance.

dkarzon
  • 7,868
  • 9
  • 48
  • 61