cancel
Showing results for 
Search instead for 
Did you mean: 

Dropbox API V2 GetAccountInfo() - C#

153 Views
10 Comments
0 Kudos
Highlighted

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
Dropboxer

Re: Dropbox API V2 GetAccountInfo() - C#

Re: Dropbox API V2 GetAccountInfo() - C#

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.
Dropboxer

Re: Dropbox API V2 GetAccountInfo() - C#

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#

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.

Dropboxer

Re: Dropbox API V2 GetAccountInfo() - C#

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)?

Level 3

Re: Dropbox API V2 GetAccountInfo() - C#

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.

Dropboxer

Re: Dropbox API V2 GetAccountInfo() - C#

Thanks! Can you try installing the SDK in both projects?

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

Re: Dropbox API V2 GetAccountInfo() - C#

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.
Dropboxer

Re: Dropbox API V2 GetAccountInfo() - C#

Apologies, I'm not sure I follow. Did you try installing the library into both of the projects you mentioned? Is it working now?