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
Ghislain Sommervogel
5 months agoHelpful | Level 5
.NET API : How to read subfolders of team folders not assigned to the connected user?
Hello, I’m developing a .NET application to automate a few tasks in Dropbox. Specifically, I need to access team folders and their subfolders. For team folders, I’m using the `DropboxTeamClient.Team...
- 5 months ago
When using the .NET SDK, using the TeamFolderListAsync method is the right way to begin listing all of the team folders for a team. Be sure to also implement TeamFolderListContinueAsync as well though, to make sure you get the whole list.
And then for any given team folder (or any folder), using ListFolderAsync and likewise ListFolderContinueAsync is the right way to list the contents of the folder. Note that if you need all of the nested entries, you'll need to set recursive: true.
But to access a team folder that your account isn't a member of, you will need to make some adjustments to the client, as you noted. You will need to:
- use DropboxTeamClient.AsAdmin to get a DropboxClient to perform the calls as an admin
- use DropboxClient.WithPathRoot using that DropboxClient to access the desired team folder. Note that in this case though, you'll want to use the (less common) PathRoot.NamespaceId mode to access the specific team folder namespace by specifying the namespace ID for the desired team folder (as opposed to the more common PathRoot.Root mode, which would access only what's in the team space for the particular connected account).
There's a blog post and accompanying code sample here about effectively the same strategy (for all team namespaces, not just team folders) if you'd like to see an example of it. The sample is written in Python, but the logic is the same.
Ghislain Sommervogel
Helpful | Level 5
Hi Greg,
Thanks for your reply. I'm just wondering how to get the NamespaceId for a specific team folder. I don't see this information in the TeamFolderMetadata class. And your example in the blog post is quite different because the starting point is a DropboxTeamClient.Team.NamespacesListAsync() call, instead of a TeamFolderListAsync() call. Obviously you get the NamespaceId in the result. Or do you suggest I switch to NamespacesListAsync()?
Best regards,
Ghislain
Greg-DB
5 months agoDropbox Staff
You don't need to switch to listing all of the namespaces unless your use case requires it. Team folders are just one type of namespace, so your scenario is effectively a subset of that example.
The namespace ID for a team folder is the team folder ID, so you can get the team folder's namespace ID from the TeamFolderMetadata.TeamFolderId.
- Ghislain Sommervogel5 months agoHelpful | Level 5
Hi Greg,
Your approach works perfectly... but triggers a new problem for the next step of my to-do list. I need to copy one of the subfolder of "team folder B" (=PathRoot of my dropboxclient) in a specific directory of "team folder A". Because of the namespaceid relocation, the source path and target path of CopyV2Async share no common root. Is there a way to solve this? In the admin console, I just click on "copy" on the right and the console let me select the target location, so I assume there is a way! 😉
- Ghislain Sommervogel5 months agoHelpful | Level 5
I think I've found the way. First set PathRoot to A NamespaceID. Use Files.CopyReferenceGetAsync(). Then set PathRoot to B NamespaceID and finally use Files.CopyReferenceSaveAsync(). Am I right? Thank you!
- Greg-DB5 months agoDropbox Staff
Yes, you can use copy references if you'd like.
Alternatively, you should also be able to use CopyV2Async as an admin from one team folder and specify the destination in the other team folder in the toPath using the format "ns:12345/copyname" where 12345 is the team folder ID of the destination team folder.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,915 PostsLatest Activity: 6 years agoIf 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!