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

Tech Dev Oldsmar's avatar
Tech Dev Oldsmar
Helpful | Level 6
7 months ago

April 2024 Update to C# Example Code => This user doesn't belong to a team with shared space

Dropbox has given ample warnings about adapting to Teams and Shared Spaces.  However, applying these updates have been staggered and this Sunday I lost all connections to team folders in a Blazor Server .NET 8 service class.   I solved it by inverting this condition:

 

if (!account.RootInfo.IsTeam)

 

 to

 

if (account.RootInfo.IsTeam)

 

I honestly don't know why this works but at least it got the production app back online. Reference to the DropboxClient WithPathRoot(PathRoot) code is here and this is the example code in case it helps anyone:

 

// Fetch root namespace info from user's account info.
var account = await client.Users.GetCurrentAccountAsync();

if (!account.RootInfo.IsTeam) // CHANGE THIS to (account.RootInfo.IsTeam)
{
    Console.WriteLine("This user doesn't belong to a team with shared space.");
}
else
{
    try
    {
        // Point path root to namespace id of team space.
        client = client.WithPathRoot(new PathRoot.Root(account.RootInfo.RootNamespaceId));
        await client.Files.ListFolderAsync(path);
    }
    catch (PathRootException ex)
    {
        // Handle race condition when user switched team.
        Console.WriteLine(
            "The user's root namespace ID has changed to {0}",
            ex.ErrorResponse.AsInvalidRoot.Value);
    }
}

 



 

 

  • iNeil's avatar
    iNeil
    7 months ago

    Hi Tech Dev Oldsmar ,

     

    Thank you for providing this information! If your account team configuration is utilizing our updated team space functionality, the expected value for account.RootInfo.IsTeam will be false, as the account will not belong to a team with a shared space.

     

    To determine the account team configuration, you will need to check the has_distinct_member_homes and has_team_shared_dropbox values while executing the /2/team/features/get_values endpoint. For further information on the latest updated team space, please review the following link:

     

     

    That said, our WithPathRoot(PathRoot) method documentation example will not work for the latest updated team space, and I have raised this to the engineering team

  • Here is the cleaned up code that now works after the switch-over update (early 2024) in re Teams/Shared Spaces:

     

    public static async Task<ListFolderResult> ListFolderInTeamSpace(DropboxClient client, string path)
    {
        try
        {
            var account = await client.Users.GetCurrentAccountAsync();
            return await client.Files.ListFolderAsync(path, client.WithPathRoot(new PathRoot.Root(account.RootInfo.RootNamespaceId)));
        }
        catch (PathRootException ex)
        {
            Console.WriteLine("The user's root namespace ID has changed to {0}", ex.ErrorResponse.AsInvalidRoot.Value);
            return new ListFolderResult();
        }
    }

     

    • iNeil's avatar
      iNeil
      Icon for Dropbox Engineer rankDropbox Engineer

      Hi Tech Dev Oldsmar ,

       

      Thank you for providing this information! If your account team configuration is utilizing our updated team space functionality, the expected value for account.RootInfo.IsTeam will be false, as the account will not belong to a team with a shared space.

       

      To determine the account team configuration, you will need to check the has_distinct_member_homes and has_team_shared_dropbox values while executing the /2/team/features/get_values endpoint. For further information on the latest updated team space, please review the following link:

       

       

      That said, our WithPathRoot(PathRoot) method documentation example will not work for the latest updated team space, and I have raised this to the engineering team

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,882 PostsLatest Activity: 14 hours ago
325 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!