Forum Discussion

prabhat1999's avatar
prabhat1999
Explorer | Level 3
7 months ago

finding the path of shared folders

I am using  dbx.sharing_list_folders() function to get all the shared folder and using folder_metadata= dbx.sharing_get_folder_metadata(shared_folder.shared_folder_id) to get the meta data of the shared folder and from this object i am retreving folder path using folder_metadata.path_lower  but it is giving None.

guide me to fetch folder path of the shared Folders

  • iNeil's avatar
    iNeil
    Icon for Dropbox Engineer rankDropbox Engineer

    Hello prabhat1999 ,

     

    If your account has the updated team configuration and you are not using the Dropbox-API-Path-Root header with the Dropbox API, the team folders and any folders nested within them won’t return the path_lower field. Additionally, if your shared folder is unmounted, it won't return the path_lower field either. This could be the reason why your path_lower value is “None”.

     

    That said, you could use the sharing_list_folders method directly to retrieve some of your path_lower values instead of looping the sharing_get_folder_metadata method with the shared_folder_id. Below I have provided an example code snippet while using the Dropbox-API-Path-Root header.

     

    # Create a Dropbox instance with an access token and using the Dropbox-API-Path-Root header
    dbx = dropbox.Dropbox('ACCESS_TOKEN')
    root_namespace_id = dbx.users_get_current_account().root_info.root_namespace_id
    dbx = dbx.with_path_root(dropbox.common.PathRoot.root(root_namespace_id))
        
    # Call the sharing_list_folders method
    result = dbx.sharing_list_folders()
    
    # Print the list of shared folders path lower value
    for entry in result.entries:
        print(entry.path_lower)