cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dropbox API V2 GetAccountInfo() - C#

Dropbox API V2 GetAccountInfo() - C#

SauravAnand01
Explorer | Level 3

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 10

Re: Dropbox API V2 GetAccountInfo() - C#

Greg-DB
Dropboxer

Re: Dropbox API V2 GetAccountInfo() - C#

SauravAnand01
Explorer | Level 3
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.

Re: Dropbox API V2 GetAccountInfo() - C#

Greg-DB
Dropboxer
There's an example of using GetCurrentAccountAsync here:

https://github.com/dropbox/dropbox-sdk-dotnet/blob/9803a40b3169acf66a2d14e29af8750ebe6e3e17/dropbox-...

Calling GetSpaceUsageAsync works similarly, but with a different return type that contains the space information instead.

Re: Dropbox API V2 GetAccountInfo() - C#

SauravAnand01
Explorer | Level 3

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.

Re: Dropbox API V2 GetAccountInfo() - C#

Greg-DB
Dropboxer

The Dropbox API v2 .NET SDK officially supports .NET Framework 4+, so you shouldn't need to upgrade to 4.5.

 

How exactly did you install it? Also, can you confirm that you installed the latest version (currently v4.3.1)?

Re: Dropbox API V2 GetAccountInfo() - C#

SauravAnand
Explorer | Level 3

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.

Re: Dropbox API V2 GetAccountInfo() - C#

Greg-DB
Dropboxer
Thanks! Can you try installing the SDK in both projects?

Also, I believe you'll need to at least install System.Net.Http.

Re: Dropbox API V2 GetAccountInfo() - C#

SauravAnand
Explorer | Level 3
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.

Re: Dropbox API V2 GetAccountInfo() - C#

Greg-DB
Dropboxer
Apologies, I'm not sure I follow. Did you try installing the library into both of the projects you mentioned? Is it working now?
Who's talking

Top contributors to this post

  • User avatar
    SauravAnand Explorer | Level 3
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?