Take Your Search Game to the Next Level with Dropbox Dash 🚀✨ Curious how it works? Ask us here!
Forum Discussion
Obaid ur Rehman
30 days agoExplorer | Level 3
New Folder is created inside another directory, not root
We have the following folder structure in Dropbox:
My Dropbox/Company/New (2025)/1 - Clients
My Dropbox/New (2025)/1 - Clients
The following code is creating the new folder in 'Company/New (2025)/1 - Clients/', but I want to create the folder in '/New (2025)/1 - Clients'.
# Step 7: Create Dropbox folder
dropbox_folder_path = f"/New (2025)/1 - Clients/client-{folder_name}"
try:
tokens = get_dropbox_tokens()
if not tokens or 'access_token' not in tokens:
raise ValueError("No Dropbox access token available")
# Initialize Dropbox client
dbx = dropbox.Dropbox(tokens['access_token'])
try:
# Check if the "1 - Clients" folder exists
clients_folder_path = "/New (2025)/1 - Clients"
try:
dbx.files_get_metadata(clients_folder_path)
except dropbox.exceptions.ApiError as e:
if e.error.is_path() and e.error.get_path().is_not_found():
logging.error(f"1 - Clients folder not found: {clients_folder_path}")
return jsonify({"error": f"1 - Clients folder not found: {clients_folder_path}"}), 404
# Create the client folder inside the existing "1 - Clients" folder
dbx.files_create_folder_v2(dropbox_folder_path)
except dropbox.exceptions.AuthError:
logging.debug("Dropbox token expired, refreshing...")
access_token = refresh_dropbox_token()
dbx = dropbox.Dropbox(access_token)
dbx.files_create_folder_v2(dropbox_folder_path)
What am I doing wrong? I've been working on the weekend and super exhausted. Any help is greatly appreciated.
Thanks!
Hi Obaid ur Rehman,
When working with Dropbox teams, by default, API calls to the Dropbox API operate in the "member folder" of the connected account, not the "team space".
You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.
1 Reply
Sort By
- DB-Des
Dropbox Engineer
Hi Obaid ur Rehman,
When working with Dropbox teams, by default, API calls to the Dropbox API operate in the "member folder" of the connected account, not the "team space".
You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,994 PostsLatest Activity: 3 minutes ago
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!