cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it 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: 

API folder creation

API folder creation

Joe_AR
Helpful | Level 5
Go to solution

I'm using Google Colab + Python to create a list of folder from a googleSheet of my open projects.  I set-up the App in dropbox & the code runs without error.  It checks to see if the folder path already exists before creation.  Ran the 1st time & received confirmation the folders were created.  Ran the 2nd time and it said the folders had already been created - this is expected on a 2nd run.  However, the folders are not appearing listed when I log in.

I've checked the path that the path is correct & that i'm navagating to the correct place in dropbox.  Is there a reason the api would return the folders are created but not visible?  Its been about 25 minutes and they're still not showing - I've heard the API sync can be delayed.

 

    for job_name, job_number in zip(job_names, job_numbers):
        folder_name = f"{job_name}{job_number}"
        folder_path = f"{parent_folder_path}{folder_name}"  # Absolute path to the new folder
        print(folder_path)
        try:
            # Check if the folder already exists
            metadata = dbx.files_get_metadata(folder_path)
            print(f"Folder '{folder_name}' already exists in Dropbox.")
        except dropbox.exceptions.ApiError as err:
            # If folder doesn't exist, create it
            if err.error.is_path() and err.error.get_path().is_not_found():
                try:
                    dbx.files_create_folder(folder_path)
                    print(f"Folder '{folder_name}' created in Dropbox.")
                except dropbox.exceptions.ApiError as err:
                    print(f"Failed to create folder '{folder_name}' in Dropbox: {err}")
            else:
                print(f"Error checking folder '{folder_name}' in Dropbox: {err}")

 

I'm not a programmer by trade/training or developer - and there's more to the code not shown here...

Is there a limit of the number of errors or attempts?  I have run this probably 100 times in the last 24 hours before I got this far.

1 Accepted Solution

Accepted Solutions

Joe_AR
Helpful | Level 5
Go to solution

Hey Zdravko,

 

Just reran it this AM and its working.  I started with the documenation and added a missing parameter.  The folders were visible when I logged in under the 'suggested folders'.  I did notice - to your point - that I was creating the folders in the wrong path.

The absolute path I was creating was wrong:

 # Define the parent folder path
    parent_folder_path = 'home/(my user name)/000 - Shipping Photos/'  # Absolute path to the parent folder

 

Should have just been:

 # Define the parent folder path
    parent_folder_path = '/000 - Shipping Photos/'  # Absolute path to the parent folder

 

Went I went to navagate to the folder upon successful creation of the folders - I noted the nested path was duplicated:

 

/home/(user  name)/000 -Shipping Photos/home/(user name)/000 - Shipping Photos/



Stupid error on top of stupid error.  Splinter removed from my mind.  Thank you for the feedback & help.

 

View solution in original post

2 Replies 2

Здравко
Legendary | Level 20
Go to solution

Hi @Joe_AR,

There are many different things that could get wrong that may lead you to such a state. It's difficult to point one (impossible actually). Typical mistakes are:

  • wrong account authenticated - you're putting files/folders in one account (authorized your application by mistake) and expect the same files/folders on other account. Check the actual account your application has linked to.
  • app folder application type - registered application type suppose limited access to associated account and all files/folders are put in the corresponding application's subfolder (not in account root), where you're looking on. Check is your application type limited to app folder in app settings.
  • team account put everything in members folder, by default - your business account assume you want to put something in your private space. Check there, not in the account root.

Of course there might be many others, but the above are most typical confusion cases and that's why you can start from them. 😉

Hope this helps.

Joe_AR
Helpful | Level 5
Go to solution

Hey Zdravko,

 

Just reran it this AM and its working.  I started with the documenation and added a missing parameter.  The folders were visible when I logged in under the 'suggested folders'.  I did notice - to your point - that I was creating the folders in the wrong path.

The absolute path I was creating was wrong:

 # Define the parent folder path
    parent_folder_path = 'home/(my user name)/000 - Shipping Photos/'  # Absolute path to the parent folder

 

Should have just been:

 # Define the parent folder path
    parent_folder_path = '/000 - Shipping Photos/'  # Absolute path to the parent folder

 

Went I went to navagate to the folder upon successful creation of the folders - I noted the nested path was duplicated:

 

/home/(user  name)/000 -Shipping Photos/home/(user name)/000 - Shipping Photos/



Stupid error on top of stupid error.  Splinter removed from my mind.  Thank you for the feedback & help.

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Joe_AR Helpful | Level 5
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?