I am trying to upload a file to the Dropbox REST web service while at the same time using Devdefined's OAuth library.
This is the method I'm using:
public static void UploadFile(string filenameIn, string directoryIn, byte[] dataIn)
{
DropBox.session.Request().Put().ForUrl("https://api-content.dropbox.com/1/files_put/" + directoryIn + filenameIn)
.WithQueryParameters(new { param = dataIn });
}
The method doesn't appear to do anything, nor throw any exceptions. There's no errors in the output either. I've tried using breakpoints to confirm it's calling the code as well.
The reason you are not receiving an error is because the request is not being executed - to execute the request you need to fetch the response - there is a number of ways to do this, but often the simplest is just to fetch the text back using the method ReadBody().
Uploading the contents of a file can not be done as a query parameter - as per the dropbox REST API, the entire body of the put request should be the file's contents.
Essentially for this all to work you will need to:
The result will be a string containing JSON that should look something like this:
I've added an example to the DevDefined.OAuth-examples project on github that demonstrates how to do GET and PUT requests with DropBox:
https://github.com/bittercoder/DevDefined.OAuth-Examples/blob/master/src/ExampleDropBoxUpload/Program.cs
And here's the code specifically required for a put request:
Hopefully that should clear things up a bit, unfortunately without documentation it's a little tricky to figure these things out by just looking at the source code :)