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

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

Path for API: path of the empty string

Hi,

I am trying to get a list of all my file and folder names. I keep getting an error message saying: 

 

The path is copied from my dropbox. So, I dont understand how it could not be found. 

Please help.

Thank you

  • Greg-DB's avatar
    Greg-DB
    7 months ago

    That's an error message from pandas, not Dropbox, so I can't offer help with that. You may want to refer to the documentation or support resources for pandas.

  • VanessaGillier's avatar
    VanessaGillier
    Explorer | Level 3

    Hi,

    I am trying to get a list of all my file and folder names. I keep getting an error message saying: 



    The path is copied from my dropbox. So, I dont understand how it could not be found. 

    Please help.

    Thank you

     
     
  • VanessaGillier's avatar
    VanessaGillier
    Explorer | Level 3

    Hello,

    I have been trying to get a complete overview of my Dropbox, Folders and File names. With some help, I was able to figure out a code. I am just getting started on coding.

    However, I keep getting the same result, saying that the folder does not exist or cannot be accessed:

    API error: ApiError('41e809ab87464c1d86f7baa83d5f82c4', ListFolderError('path', LookupError('not_found', None)))
    Folder does not exist or could not be accessed.
    Failed to retrieve files and folders.

     

    this is the code;

    import dropbox
    import pandas as pd

    # Replace 'YOUR_ACCESS_TOKEN' with your new access token
    dbx = dropbox.Dropbox('TOKEN')

    # Define a function to list files and folders
    def list_files_and_folders(folder_path):
    try:
    response = dbx.files_list_folder(folder_path)
    entries = response.entries
    if entries:
    file_names = []
    folder_names = []
    for entry in entries:
    if isinstance(entry, dropbox.files.FolderMetadata):
    folder_names.append(entry.name)
    elif isinstance(entry, dropbox.files.FileMetadata):
    file_names.append(entry.name)
    return file_names, folder_names
    else:
    print("Folder is empty.")
    return None, None
    except dropbox.exceptions.ApiError as e:
    print(f"API error: {e}")
    print("Folder does not exist or could not be accessed.")
    return None, None
    except Exception as ex:
    print(f"An unexpected error occurred: {ex}")
    return None, None

    # Specify the Dropbox folder path
    folder_path = '/Vanessa Gillier/Rioblanco Capital LLC'

    files, folders = list_files_and_folders(folder_path)

    # Check if files and folders are retrieved successfully
    if files is not None and folders is not None:
    # Create a DataFrame
    df = pd.DataFrame({'File Name': files, 'Folder Name': folders})

    # Export to Excel
    df.to_excel('dropbox_contents.xlsx', index=False)
    print("Files and folders retrieved successfully.")
    else:
    print("Failed to retrieve files and folders.")

     

    The permissions are all in order, when I use cd to go to the correct location, it finds it without a problem. Where could the problem lie?

    I have removed the access token, but this is also to correct one copies straight from the location. I have also removed the location for privacy reasons, I hope you are still able to help me?

    If there are other ways of doing this please inform me.

    Thank you for your help.

     

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

      I see you're including your user name in the "folder_path" value, but note that the root for API calls defaults to your member folder automatically, so you shouldn't include the name of the member folder. Try taking out that path component.

       

      Also, when calling 'files_list_folder', you can supply a 'path' of the empty string '' to list the root for the call. That's generally a helpful first step for debugging issues like this.

      • VanessaGillier's avatar
        VanessaGillier
        Explorer | Level 3

         

        This is my new code after removing my username. but the problem remains. 

        The second part of you answer also confuses me a bit, although I believe I did it.

        I am very new to all of this, so dumming it down might be useful.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,882 PostsLatest Activity: 3 years ago
325 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!