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

havetoregister's avatar
havetoregister
Helpful | Level 6
7 years ago

Get list of files in folders inside shared folders

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.

  • havetoregister's avatar
    havetoregister
    7 years ago

    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!

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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.

    • havetoregister's avatar
      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?

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        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.)