cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right 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 Using .NET SDK Files.ListFolderAsync Returns Empty

Dropbox API Using .NET SDK Files.ListFolderAsync Returns Empty

WMoerke
Explorer | Level 3
Go to solution

I am using the .NET SDK to interact with dropbox, and I cannot get it to return anything when using Files.ListFolderAsync.  I am able to get it to work correctly when using my own personal dropbox, but when I connect to a client's dropbox it is empty.  I have verified that they have folders and files in the folder, and that they have granted files.content.read permissions.  I have also tested that the connection is working by using:

var checkResult = await _DropboxClient.Check.UserAsync("The check is good");

 

That returns successfully.  Any ideas on what I am missing here?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

There are a few things to check here:

  • Make sure you're connected to the account that you mean to access. You can use GetCurrentAccountAsync to check the account for the access token you're currently using.
  • Is the access token you're using in that case connected to an app with the "app folder" access type? If so, note that it would only be able to access the special "app folder" created in the account, and not any other folders. App folders are created empty.
  • Is the access token for an account that's on a team that uses the "team space" configuration, and if so, are the files and folders you're expecting to see located in the "team space" or the "member folder"? In that case, if the member folder is empty, you wouldn't get any results since API calls default to the member folder and not the team space. You can information on this, including how to access the team space instead, in the Team Files Guide.
  • Is ListFolderResult.HasMore being returned as true? Note that you're not necessarily guaranteed to get any/all results back on a single page, so if ListFolderResult.HasMore is true, make sure to call back to ListFolderContinueAsync, as documented for ListFolderAsync.

By the way, for reference, listing the items in a folder requires "files.metadata.read", not "files.content.read", but regardless, you'd get a more specific error if you didn't have the necessary scope authorized, not just an empty list.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

There are a few things to check here:

  • Make sure you're connected to the account that you mean to access. You can use GetCurrentAccountAsync to check the account for the access token you're currently using.
  • Is the access token you're using in that case connected to an app with the "app folder" access type? If so, note that it would only be able to access the special "app folder" created in the account, and not any other folders. App folders are created empty.
  • Is the access token for an account that's on a team that uses the "team space" configuration, and if so, are the files and folders you're expecting to see located in the "team space" or the "member folder"? In that case, if the member folder is empty, you wouldn't get any results since API calls default to the member folder and not the team space. You can information on this, including how to access the team space instead, in the Team Files Guide.
  • Is ListFolderResult.HasMore being returned as true? Note that you're not necessarily guaranteed to get any/all results back on a single page, so if ListFolderResult.HasMore is true, make sure to call back to ListFolderContinueAsync, as documented for ListFolderAsync.

By the way, for reference, listing the items in a folder requires "files.metadata.read", not "files.content.read", but regardless, you'd get a more specific error if you didn't have the necessary scope authorized, not just an empty list.

WMoerke
Explorer | Level 3
Go to solution

Hi Greg, thanks for the reply.

 

I was able to confirm that it is the correct account by using GetCurrentAccountAsync.  Unfortunately, when I was confirming with my client that he created the app with full dropbox access he wasn't sure and decided to delete it and create it over again.  After he did that I am having a bit of a different error.  I am now getting an exception saying my app does not have the required scope 'files.metadata.read'.  My client sent me a screenshot of the permissions though, and that scope is checked.  Is it possible it takes a while for the permissions to kick in?

Greg-DB
Dropbox Staff
Go to solution

There isn't a delay, but note that scope changes are not retroactive. That is, if you enable a scope on an app, that does not retroactively add that scopes to existing tokens that were authorized before the scope was enabled. If the scope was enabled after connecting the app, the user would need to authorize the app again to grant the newly enabled scope.

WMoerke
Explorer | Level 3
Go to solution

It turns out the problem with this was that my client didn't realize he needed to hit the submit button at the bottom after changing permissions.  After he did that and I got a new refresh token, I am now able to see the folder structure using Files.ListFolderAsync.  I am not sure what the issue was before where I got an empty list returned from ListFolderAsync, but that seems to be cleared up now.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    WMoerke Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?