← 输入框|github.com|刷新
Skip to content
This repository was archived by the owner on Nov 29, 2021. It is now read-only.
This repository was archived by the owner on Nov 29, 2021. It is now read-only.

.NET 4.5 GetFile Method Exception #136

Open

Description

@emasmind

I get exceptions when using GetFile method in .NET 4.5. The exceptions are:

A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'DropNet.Exceptions.DropboxException' occurred in DropNet.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'DropNet.Exceptions.DropboxException' occurred in DropNet.dll
A first chance exception of type 'DropNet.Exceptions.DropboxException' occurred in System.dll

The UploadFile method works fine.

Activity

  1. dkarzon commented on Nov 21, 2014

    @dkarzon
    Member

    Do you have any details on the exceptions?
    Maybe attach a fiddler session to see what the API response is?

  2. emasmind commented on Nov 21, 2014

    @emasmind
    Author

    I get this:

    The remote server returned an error: (401) Unauthorized.

  3. emasmind commented on Nov 21, 2014

    @emasmind
    Author

    You can reproduce the error by using the WindowsForms sample changing the target framework to .NET 4.5

  4. emasmind commented on Nov 21, 2014

    @emasmind
    Author

    From the dropbox's documentation (https://www.dropbox.com/developers/core/docs):
    401 Bad or expired token. This can happen if the user or Dropbox revoked or expired an access token. To fix, you should re-authenticate the user.

  5. dkarzon commented on Nov 21, 2014

    @dkarzon
    Member

    Sounds like you haven't authenticated. Do the other API calls work like GetMetadata?

    Is your API key full dropbox or app folder permissions? If its app folder are you seeing the sandbox flag?

  6. emasmind commented on Nov 22, 2014

    @emasmind
    Author

    Please try this, using a .NET 4.5 project

        private void brwLogin_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.Host.Contains("google"))
            {
                //Callback url reached, user has completed authorization
    
               //Access the App folder
                _client.UseSandbox = true;
    
                //Now convert the request token into an access token
                _client.GetAccessTokenAsync((userLogin) =>
                    {
                        //Save the Token and Secret we get here to save future logins
                        _userLogin = userLogin;
    
                        GetContents();
                    },
                    (error) =>
                    {
                        //Some sort of error
                        MessageBox.Show(error.Message);
                    });
            }
        }
    
        private void GetContents()
        {
            _client.GetMetaDataAsync("/", (response) =>
            {
                byte[] data = _client.GetFile("note.txt");
                File.WriteAllBytes(@"C:\note.txt", data);
                data = null;
            },
            (error) =>
            {
                Console.WriteLine(error.Message);
            });
    
        }
    

    It works on .NET 4.0, but it doesn't work on .NET 4.5

    Thank you
    Elias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions