cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: How to get relative path of file in team folder?

How to get relative path of file in team folder?

dochdl
Helpful | Level 6
Go to solution

My app tracks the files and keeps the metadata in my db and I do it by frequently calling list_folder/continue
I recently added support to team folders
I so I use path: "ns:<namespace_id>" to get the content
When I get the metadata of the file I get no path in the response, only the parent_shared_folder_id
The problem is when I have a sub-folder inside the team folder
for ex: /Marketing/Sub-folder/file.txt
I still get the parent_shared_folder_id of Marketing, so I can't know it is in a sub folder
I tried using get_metadata with the file's id but still no path

I actually need it to run delete operations, so if there is a way to use the id it will also be fine
This is the only way I was able to delete a file in a team folder using this path
{"path":"ns:2464786112/Sub_Marketing/file25042018_1555.pdf"}
(ns:2464786112 is Marketing namespace id)

I was able to delete files with only id in the path but only files that are in the user's account and not files in a team folder.
I'm using a team token and tried all variations with Dropbox-Api-Select-Admin header and Dropbox-Api-Select-User header and wasn't able to delete
I keep getting path_lookup/not_found/

So either getting the relative path or deleting by id will be good for me. (If I can do both I would like to know also)
Thanks

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

To get the relative paths for items in the team space, you should use the "Dropbox-API-Path-Root" to set the root for the API call to that team space. You can find more information in the namespace guide:

 

https://www.dropbox.com/developers/reference/namespace-guide

 

For example, that would look like this:

 

 

curl -X POST https://api.dropboxapi.com/2/files/list_folder \
    --header 'Authorization: Bearer <ACCESS_TOKEN>' \
    --header 'Dropbox-API-Select-User: <MEMBER_ID>' \
    --header 'Content-Type: application/json' \
    --header 'Dropbox-API-Path-Root: {".tag": "root", "root": "<NS_ID>"}' \
    --data "{\"path\": \"\"}"

Also, using that, you can delete either via path or id.

 

View solution in original post

1 Reply 1

Greg-DB
Dropbox Staff
Go to solution

To get the relative paths for items in the team space, you should use the "Dropbox-API-Path-Root" to set the root for the API call to that team space. You can find more information in the namespace guide:

 

https://www.dropbox.com/developers/reference/namespace-guide

 

For example, that would look like this:

 

 

curl -X POST https://api.dropboxapi.com/2/files/list_folder \
    --header 'Authorization: Bearer <ACCESS_TOKEN>' \
    --header 'Dropbox-API-Select-User: <MEMBER_ID>' \
    --header 'Content-Type: application/json' \
    --header 'Dropbox-API-Path-Root: {".tag": "root", "root": "<NS_ID>"}' \
    --data "{\"path\": \"\"}"

Also, using that, you can delete either via path or id.

 

Need more support?