Forum Discussion

SauravAnand01's avatar
SauravAnand01
Explorer | Level 3
9 years ago

Dropbox API V2 GetAccountInfo() - C#

I'm migrating from Dropbox v1 to v2, how can i proceed with GetAccountInfo() to get details such as:
UserName, UserId, QuotaUsed, QuotaAvailable, SharedUse.

How do i get this with v2.

Previously by using v1 it was like:

var accessToken = new OAuthProtocol.OAuthToken(auth_Token, auth_Token_Secret);
var api = new DropboxApi(dropbox_appkey, dropbox_appsecret, accessToken);
var accountInfo = api.GetAccountInfo();

Thank you.

10 Replies

  • SauravAnand01's avatar
    SauravAnand01
    Explorer | Level 3
    9 years ago
    Hi Greg,

    Thanks for your prompt response. Can you please provide a code block/example of any of the above method call so that i can proceed with my other various API calls and complete my migration from v1 to v2.

    Only one code block or example will be really helpful.

    Thank you.
  • SauravAnand01's avatar
    SauravAnand01
    Explorer | Level 3
    9 years ago

    Thank you for the example.

    I have installed Dropbox API v2 library in a project which target framework is 4.0 and calling GetCurrentAccountAsync() as you have suggested then i'm getting exception like "Could not load file or assembly 'Dropbox.Api, Version=4.0.0.0, Culture=neutral, PublicKeyToken=310f0e82fbb45d01' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

    Do i need to change target framework to 4.5 or is there any way to fix this exception. If i will have to change framework then it will be major change for my project.

  • SauravAnand's avatar
    SauravAnand
    Explorer | Level 4
    9 years ago

    Hi Greg,

     

    I have one of my winform project (framework 4.0) then added one more project name "dropboxV2" (framework 4.0) to the same solution and set this project output type as "Class Library". I went to package manager console then run "Install-Package Dropbox.Api", after completion i got "Successfully installed 'Dropbox.Api 4.3.1' to dropboxV2".

     

    I have a class like in newly added project:

    public async void GetCurrentAccount(string accessToken)
    {
         using (var client = new DropboxClient(accessToken))
          {
               var fullAccount = await client . 
                Users.GetCurrentAccountAsync();               
          }
    }

    Now i'm accessing above method from my main project as:

    dropboxV2.DropboxHelper helper = new dropboxV2.DropboxHelper();
    helper.GetCurrentAccount(access_token); // here i'm getting exception

    What i'm doing wrong here? Please help.

    Thank you.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Thanks! Can you try installing the SDK in both projects?

    Also, I believe you'll need to at least install System.Net.Http.
  • SauravAnand's avatar
    SauravAnand
    Explorer | Level 4
    9 years ago
    No, i have managed to install Dropbox.Api v2 into my main project itself and System.Net.Http is installed too.

    Thanks for your support.
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Apologies, I'm not sure I follow. Did you try installing the library into both of the projects you mentioned? Is it working now?
  • SauravAnand's avatar
    SauravAnand
    Explorer | Level 4
    9 years ago
    Hi Greg,

    I have removed the extra project which i mentioned earlier and installed Dropbox API in the main project itself, now all is working fine.

    It was a conflict between Dll's of the both project. Previously v1 was referenced in my main project and v2 is referenced into another project, and i was calling another project's function from my main project. Due to this i was getting "Could not load file or assembly" exception.

    But now all working fine. One more query i have about UploadAsync() which i have created a new thread.

    Thank you Greg for your support.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!