You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

WMoerke's avatar
WMoerke
Explorer | Level 3
2 years ago

Dropbox API Using .NET SDK Files.ListFolderAsync Returns Empty

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?

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

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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's avatar
      WMoerke
      Explorer | Level 3

      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's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 Following

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 or Facebook.

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!