cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
If you’ve changed your email address, now's the perfect time to update it on your Dropbox account and we’re here to help! Learn more 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: 

How to ListFolderAsync to a folder in the root folder?

How to ListFolderAsync to a folder in the root folder?

cristpol95
Explorer | Level 4

Currently, I am trying to connect a WPF C# app to my Dropbox. I have the folders organized in the way you see in the image. Leaving the string empty opens the "Student" folder, however I want my app to list the contents "code" folder. I have tried using "code", "\\code", "/code" but the app always throws a path not found error.

 

I am not sure what I am doing wrong, any help is appreciated! If you need any more information, please let me know.

 

Thank you!

 

a.png

private async Task<List<FolderViewModel>> FetchFoldersAsync(string accessToken)
{
    var items = new List<FolderViewModel>();

    using (var dbx = new DropboxClient(accessToken))
    {
        var list = await dbx.Files.ListFolderAsync("");

        MessageBox.Show(list.Entries.ToString());

        foreach (var item in list.Entries)
        {
             BitmapImage thumbnail = null;

             if (!item.IsFolder)
             {
                  thumbnail = await FetchThumbnailAsync(dbx, item.PathDisplay);
              }

              items.Add(new FolderViewModel
              {
                   Name = item.Name,
                   Thumbnail =
                   thumbnail ?? new BitmapImage(new 
                   Uri("pack://application:,,,/Resources/Images/folder-icon.png", 
                   UriKind.RelativeOrAbsolute)),
               });
          }
     }
     return items;
}
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff

By default, API calls to the Dropbox API operate in the "member folder" of the connected account ("Student", in your case), not the "team space". That means that by default, the contents of the team space will not be found.

 

You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff

By default, API calls to the Dropbox API operate in the "member folder" of the connected account ("Student", in your case), not the "team space". That means that by default, the contents of the team space will not be found.

 

You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

cristpol95
Explorer | Level 4

Thanks a lot for your response! I applied this to my project, I am now able to connect to the "code" folder.

Need more support?
Who's talking

Top contributors to this post

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