Take Your Search Game to the Next Level with Dropbox Dash 🚀✨ Curious how it works? Ask us here!
Forum Discussion
Charles Knight
2 months agoNew member | Level 2
Create new folder in existing Team Folder
Hi,
I use a web site development program called Wappler which allows for the setup of API's
It has a section for the URL of the API, JSON DATA and I can add headers.
I used the default:
https://api.dropboxapi.com/2/files/create_folder_v2
and added the headers:
"Authorization: Bearer <my token here>" \
"Content-Type: application/json" \
and in the Json Data box I put:
{ "autorename": false, "path": "/Homework/math/{{$_POST.foldername}}" }
This works OK and creates a folder from my form input to my home folder inside a folder called Apps> Homework/math/myfoldernamefrom form
I want to create the folder in the team space so I added the Dropbox-API-Path-Root header and the value {".tag": "root", "root": "7"}, along with the following in the Json Data:
{
"path": "{{$_POST.foldername}}"
}
I know the 7 is just a sample and I have the details of my user ID, at the bottom is the root_info, with .tag, the root_namespace_id, the homespace_id and my home_path.
What do/would I put in the Json Data to create a folder in team space called CompanyOne>FolderOne
Many thanks for your help
5 Replies
Sort By
- Charles KnightNew member | Level 2
Would you be able to help me construct an api action using the offline access method?
- DB-Des
Dropbox Engineer
Dropbox does not offer the option for creating long-lived, or permanent, access tokens. Dropbox issues short-lived access tokens (and optional refresh tokens) instead.
When you use one of our official SDKs, you do not need to implement all of the logic for "offline" access yourself. The SDK will do most of the work for you. You can find examples of this in each SDK repository. There's also a basic outline of processing this flow in this blog post which may serve as a useful example.
- Charles KnightNew member | Level 2
Hi DB-Des,
I sort of managed to get things working by good old trial and error, although I'm not sure if it's the most elegant way!
I ended up with four headers:,
Authorisation (Bearer string),
Content-Type (application/json),
Dropbox-API-Path-Root (in my case {".tag": "namespace_id", "namespace_id": "<root_namespace_id>"} worked but I got an error saying that I needed to specify a user in the team),
Dropbox-API-Select-User (team_member_id here)As for the Json Date:
{
"path": "/Folder1/Folder2/{{$_POST.foldername}}"
}{{$_POST.foldername}} being data from my form
What I have just found though is, my Bearer token has expired from last night, so how to I created a permanent authorisation between my API Action and DropBox?
- Charles KnightNew member | Level 2
Maybe I should have added, what should I put in the header instead of:
{".tag": "root", "root": "7"}
Would it be
{".tag": "user", "root_namespace_id": "12345678-my-number-in-here"- DB-Des
Dropbox Engineer
Hi Charles Knight,
To create a folder in your team space, the usage of "Dropbox-API-Path-Root" is correct.
In order to get your team's team space ID, you can send a request to /2/users/get_current_account to get your user's details. Make sure you are grabbing the "root_namespace_id" value within the "root_info" property from the response.
This is the value you'd then pass in the "Dropbox-API-Path-Root" header as the root. The way you had it formatted first is correct:
{".tag": "root", "root": "<root_namespace_id>"}
Let us know if you are still experiencing any issues or unexpected behavior.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,001 PostsLatest Activity: 3 hours 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!