cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: Getting files from a non root namespace

Getting files from a non root namespace

dochdl
Helpful | Level 6
Go to solution

Hi
I want to be able to track all changes in all folders
including in namespaces that are not a root user's root folder
I use a team token. 

When I use /list_folder with the Dropbox-API-Select-User header, and path="" and recursive=true
I only get the root folder for that user
I also tried this with the Dropbox-API-Select-Admin header but I got the admin's root folder

And /namespaces/list only gets the namespaces but without the folders\files inside.
What is the api I need to use?
I also want to move to push notifications, will I get push notifications on folders inside such a namespace?

And another thing, why a user's root folder in UI and in log_events apprears as the user's name and in the list if namespaces it appears as "root"?

Thanks you

1 Accepted Solution

Accepted Solutions

dochdl
Helpful | Level 6
Go to solution

So seems as if using Dropbox-Api-Select-Admin header solves the problem
However, it does not appear in your documentation

so the answer is using this request:
POST /2/files/list_folder
Host: https://api.dropboxapi.com
Authorization: Bearer <token>
Content-Type: application/json
Dropbox-Api-Select-Admin: dbmid:AAA...Rw

{
"path": "ns:2464786048",
"recursive": true
}

View solution in original post

7 Replies 7

Greg-DB
Dropbox Staff
Go to solution

If you have a Dropbox Business API app with the "team member file access" permission, using /2/files/list_folder with the Dropbox-API-Select-User header and path="" and recursive=true is the right way to list the all of the contents of a user's account.

 

You can also specify a namespace in the path value instead. Check out the Namespace Guide for information on doing that.

 

Make sure you check the `has_more` value in the result returned by /2/files/list_folder though. If it's true, you need to call back to /2/files/list_folder/continue to get more entries.

 

If you want, you can register for webhooks to get notified of changes automatically. Be sure to check out the webhooks documentation for Business apps in particular too.

 

I'm not sure I understand your last question though. Can you clarify?

dochdl
Helpful | Level 6
Go to solution

Hi
Thanks for the answer but it doesn't work
I got the namespace id from namespaces/list
Then I used list_files with path=ns:<namespace_id> and I fot path not found

The question about webhooks was how will I get the notification on a change in a shared\team folder. Will I get all the ids of all users in the notification? If so, is it a must? in that case I would prefer to poll changes in those folders. 

Regarding the different path issue:
for ex: 
let's say user1 adds 1 file to it's root folder and calls it file1
When I ask for list_folders with path="" for user1 the path I will get for it will be '/file1'
but the log event for the creation of the file will give me a different path '/user1/file1'
why is that?

Greg-DB
Dropbox Staff
Go to solution

For the issue listing the namespace by namespace ID, please share some sample code and full output so I can take a look.

 

Yes, if you register a Dropbox Business API app for team member file access notifications, you will get notified for changes to any member account. From the documentation:

 

"Note that a single change to a file in a shared folder will trigger a webhook for each user that the folder is shared with (and will also show up in the /list_folder entries for each account)."

 

Finally, the matter of the different paths sounds like a result of the new team space and member folders configuration. When you're using /2/files/list_folder[/continue] for a specific user, the paths are already relative to that member's folder. When you're using the audit log, on the other hand, the paths are relative to the team space itself, so it will contain the member folder name.

dochdl
Helpful | Level 6
Go to solution

So I probably used a wrong token before
I did it again and now it's working, thanks!

dochdl
Helpful | Level 6
Go to solution
So it wasn't a wrong token
It is working for the root directory of a user but not for other namespaces
for ex (from your api explorer):
POST /2/files/list_folder
Host: https://api.dropboxapi.com
User-Agent: api-explorer-client
Authorization: Bearer <token>
Content-Type: application/json
Dropbox-Api-Select-User: dbmid:AAA...Rw

{
"path": "ns:2464419056",
"recursive": true
}

returns results. this namespace is a root folder for the user in the header "Dropbox-Api-Select-User" (type=team_member_folder)

but this request returns path not found:
POST /2/files/list_folder
Host: https://api.dropboxapi.com
User-Agent: api-explorer-client
Authorization: Bearer <token>
Content-Type: application/json
Dropbox-Api-Select-User: dbmid:AAA...Rw

{
"path": "ns:2464786048",
"recursive": true
}

here it is the team's shared space (type=team_folder)
I get the same error for the default "Marketing" namespace (type=shared_folder)

dochdl
Helpful | Level 6
Go to solution

So seems as if using Dropbox-Api-Select-Admin header solves the problem
However, it does not appear in your documentation

so the answer is using this request:
POST /2/files/list_folder
Host: https://api.dropboxapi.com
Authorization: Bearer <token>
Content-Type: application/json
Dropbox-Api-Select-Admin: dbmid:AAA...Rw

{
"path": "ns:2464786048",
"recursive": true
}

chirstius
Dropbox Staff
Go to solution

@dochdl for future reference, the Select-Admin header is covered in our Business Endpoints documentation under "Member file access":

 

https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access 

Need more support?