简体   繁体   English

使用DropNet的例外情况

[英]Exception using DropNet

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. 所以我是新手使用外部API进行项目,但我有一个想法,我想看看我是否可以正确地将文件上传到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. DropNet.dll中发生未处理的“System.ArgumentNullException”类型异常附加信息:值不能为空。

Update: Looking into the error further the actual parameter that is null would be "userLogin"** 更新:进一步查看错误,null的实际参数将是“userLogin”**

This is my code before the error: //using Dropnet; 这是我在错误之前的代码://使用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: 或者我的OAuth uri可能是不正确的,我不太确定,但是如果这里重要的是我的Dropbox开发者页面的样子:

我的Dropbox页面 If you need any more information please let me know, thanks for any help! 如果您需要更多信息,请告诉我,谢谢您的帮助!

Fixed: needed to add a simple snipped of code underneath my deceleration of _client 修复:需要在_client减速下面添加一个简单的剪切代码

UserLogin login = _client.GetToken();
_client.UserLogin = login;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM