cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know all about tools for creatives that work seamlessly with Dropbox, like Adobe? Well, check it out 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: 

Get list of files in folders inside shared folders

Get list of files in folders inside shared folders

havetoregister
Helpful | Level 6

Hi there,

 

I am having a lot of trouble getting the contents of shared folders and the content of folders within shared folders.

 

Firstly, for the shared folder, according to the API I should be able to use https://api.dropboxapi.com/2/files/list_folder with "path": "id:{shared folder id}", however this returned a `path not found`.

 

So I had to get the preview url in the metadata of the shared folder, then use https://api.dropboxapi.com/2/files/list_folder with "path": "" and "shared_link":{"url": "{shared link}" I thought this was a bit of an unusual workaround.

 

Now for each file in the shared folder I can't access those using https://api.dropboxapi.com/2/files/list_folder with their ids, and they don't have shared links.

 

My questions:

 

a) Is it possible to access shared folder content via the Dropbox API?

b) If I can do this with a path, what is the path to shared folders? It's not relative to the root directory.

1 Accepted Solution

Accepted Solutions

Re: Get list of files in folders inside shared folders

havetoregister
Helpful | Level 6

Hey Greg, this has been resolved.

 

When setting up a Dropbox API Key for `App Folder` or `Full Access`, you don't have access to the Shared folders until the user manually Adds the folder to their Dropbox account.

 

The account I was accessing had not done this. Issue resolved now. 🙂

 

Thank you very much for your patience and help in trying to get me through this!

View solution in original post

8 Replies 8

Re: Get list of files in folders inside shared folders

Greg-DB
Dropboxer

Yes, you can list the contents of shared folders mounted in an account using the /2/files/list_folder[/continue] endpoints like any other folder. You have a few options for doing so:

  • by full path in the 'path' parameter, e.g.: "/path/to/shared/folder"
  • by folder ID in the 'path' parameter, e.g.: "id:abcd1234" (where 'id:abcd1234' is the 'id' for the folder)
  • by shared folder ID as a namespace ID in the 'path' parameter, e.g.: "ns:12345678" (where '12345678' is a shared folder ID)

It sounds like you're combining the last two, i.e., using the shared folder ID as a normal file/folder ID, which won't work. You can find some more information in the Namespace Guide.

 

To get the paths and IDs for any items in the account, you can start by calling /2/files/list_folder[/continue] for root, supplying the empty string "" as the 'path' parameter.

Re: Get list of files in folders inside shared folders

havetoregister
Helpful | Level 6
  • "by full path in the 'path' parameter, e.g.: "/path/to/shared/folder""
    • What is the path to a shared folder relative to the root? I can't get this information in the shared folder metadata.  You stated I could get the paths and IDs for any items in the account by "calling /2/files/list_folder[/continue] for root, supplying the empty string "" as the 'path' parameter." but this doesn't display shared folders.

 

  • "by folder ID in the 'path' parameter, e.g.: "id:abcd1234" (where 'id:abcd1234' is the 'id' for the folder)"
    • I've done this with the ids of folders inside shared folders and I get the "path/not_found/" error.

 

  • "by shared folder ID as a namespace ID in the 'path' parameter, e.g.: "ns:12345678" (where '12345678' is a shared folder ID)"
    • I've done this with the shared_folder_id and I get the "path/not_found/" error

 

Can you tell me how to get a) the contents of a shared folder, and b) the contents of the folders inside a shared folder on a Dropbox Account (not a Dropbox for Business Account) via the HTTP API? The instructions you've given me are not working so is there a problem with my account?

Re: Get list of files in folders inside shared folders

Greg-DB
Dropboxer

The path to a shared folder would be the 'path_lower' value for the FolderMetadata object for the folder, e.g., as returned by /2/files/list_folder.

 

The id of a folder would be the 'id' value for the FolderMetadata object for the folder, e.g., as returned by /2/files/list_folder.

 

The shared folder ID would be the 'shared_folder_id' value for the FolderMetadata object for the folder, e.g., as returned by /2/files/list_folder.

 

These values should all be returned for the respective entries by /2/files/list_folder, e.g., when you list the root folder as I mentioned in my last post. (Note that if your team is using the "team space" configuration, and you're looking for folders in the team space itself, that will work slightly differently. You can find more information about that in the Namespace Guide. I don't have any particular reason to believe that's relevant in your case given your posts, but I'm mentioning it just in case.)

 

Anyway, if things don't seem to be working properly, please feel free to share some sample code and output, e.g., for the /2/files/list_folder call for root, etc., so we can take a look. (You can open an API ticket with the details if you want to share privately instead.)

Re: Get list of files in folders inside shared folders

havetoregister
Helpful | Level 6

Hi Greg,

 

Using /2/files/list_folder only works if I access this through the shared link of a shared folder, (shared_link parameter with url, path set to empty string), and I still can't get access to the folders within that shared folder using this because they don't have shared links.

 

The lower_path of the shared folder does not display when I retrieve metadata with files/list_folder, nor with sharing/get_folder_metadata, so I cannot access the shared folders via path, can you tell me if there is a default path for shared folders relative to the root?

 

I notice both shared folders that I want to access have "is_inside_team_folder": true.

 

If shared folders are within team folders, does this mean that I cannot access them unless I have a Dropbox Business API app key?

 

Re: Get list of files in folders inside shared folders

havetoregister
Helpful | Level 6

Hey Greg, this has been resolved.

 

When setting up a Dropbox API Key for `App Folder` or `Full Access`, you don't have access to the Shared folders until the user manually Adds the folder to their Dropbox account.

 

The account I was accessing had not done this. Issue resolved now. 🙂

 

Thank you very much for your patience and help in trying to get me through this!

View solution in original post

Re: Get list of files in folders inside shared folders

amm98d
New member | Level 2

Finally got this work after an hour. Dropbox API has extremely poor documentation. 

Re: Get list of files in folders inside shared folders

apo1397
Explorer | Level 4

Hey @havetoregister @Greg-DB ,
"Add to Dropbox" works for folders but any idea about shared files ?
Cuz they don't have this feature and while long polling or webhooks, Dropbox doesnt give the details of the file which was shared to the user. 

Re: Get list of files in folders inside shared folders

Greg-DB
Dropboxer

@apo1397 "Shared folders" and "shared files" work a bit differently unfortunately. You can't add or "mount" a shared file in an account like you can with a shared folder.

Poll
Do you work or study in the creative industry? If so, which area?
If you use Adobe, don't forget to check out our latest integrations update here.
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    apo1397 Explorer | Level 4
  • User avatar
    amm98d New member | Level 2
  • User avatar
    havetoregister Helpful | Level 6
What do Dropbox user levels mean?
Need more support?