Question

So I'm new to using external API's for projects, but I had an idea and I'd like to see if I can properly get files uploaded to dropbox. I've gone through the steps to get the key and token, and I've begun testing but I have run into an error:

An unhandled exception of type 'System.ArgumentNullException' occurred in DropNet.dll Additional information: Value cannot be null.

Update: Looking into the error further the actual parameter that is null would be "userLogin"**

This is my code before the error: //using Dropnet;

DropNetClient _client = new DropNetClient("API_KEY", "API_SECRET", DropNetClient.AuthenticationMethod.OAuth1);

The code that produces the error:

var url = _client.BuildAuthorizeUrl();

And my code following the error:

Process.Start(url);
_client.GetAccessTokenAsync((accessToken) =>
    {
        _client = new DropNetClient("API_KEY", "API_SECRET", accessToken.Token, accessToken.Secret);
    },
    (error) =>
    {
        MessageBox.Show(error.Message);
    });
try
{
    _client.UploadFile("/", "test.txt", ReadFile(@"D:\Classes\Documents\test.txt"));

    MessageBox.Show("Successfully uploaded to Dropbox.", "Uploaded to Dropbox");
}
catch (Exception dropboxEx)
{
    MessageBox.Show("Error: " + dropboxEx.Message);
}

I am fairly sure the error has something to do with the deceleration of the client, perhaps I'm misusing the key and secret? Or my OAuth uri could possibly be incorrect, I'm not really sure but in case it matters here is what my dropbox developer page looks like:

My Dropbox Page If you need any more information please let me know, thanks for any help!

Was it helpful?

Solution

Fixed: needed to add a simple snipped of code underneath my deceleration of _client

UserLogin login = _client.GetToken();
_client.UserLogin = login;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top