Setup Dropbox API to create folder in Wappler

Hi All,

I want to create button that when clicked will take user enter info and create a folder in a Dropbox account.

Dropbox have a developer site which shows the following example for doing this.

Would anyone be willing to show me how the example could be implemented
in Wappler?

Hello @cknight
On your server action just place an API step with the data you see there

curl -X POST https://api.dropboxapi.com/2/files/create_folder_v2 \
    --header "Authorization: Bearer <get access token>" \
    --header "Content-Type: application/json" \
    --data "{\"autorename\":false,\"path\":\"/Homework/math\"}"
Parameters
{

Means:

Method: Post
Url: https://api.dropboxapi.com/2/files/create_folder_v2

Create 2 header inputs:
Authorization: Bearer your api token
Content-Type: application/json

Data: json

{
    "autorename": false,
    "path": "/Homework/math"
}

Sorry, where in the API Action Properties do I place that data, is it in the Input Data area?

Change data type, select json
And paste this:

{
    "autorename": false,
    "path": "/Homework/math"
}

Have done that and guessed I then put the --header and the "Authorization: Bearer " \ in this box?

I know I need my access token, when I click he link it changes to a really long random number. Do I remove the " " marks at each end and the trailing slash \

On name: Authorization
On value: Bearer here the access token

OK, great. Tried that but when I Fetch Schema in Schema Editor it says I have a folder conflict.
In the "{"autorename":false,"path":"/Homework/math"}" I changed the /Homework/math\ to the location where I want to create the new folder "{"autorename":false,"path":"/MyFolder/Test1"}"

Can you post the exact error here?

Hi Franse,

In the JSON path I have put the path I see when I navigate to the folder I want to create another folder in, in this case I have just called it aaaa.

As you can see the Fetch Schema comes back with a conflict error.

Also I have noticed the Auth key has changed from yesterday, am I betther off using Oauth2?

If I were you I'd use n8n

You can't just use the Fetch Schema on an API that uses POST and a Bearer token to be sent.

You can get the response from the docs, paste it and click the Run button so that the schema is generated based on this response:

{
"metadata": {
"name": "math",
"path_lower": "/homework/math",
"path_display": "/Homework/math",
"id": "id:K6FuXcBNgM8AAAAAAAAADQ"
}
}

Everything works perfectly fine when i run the server action and the folder is being created:

results:

Screenshot 2025-03-20 at 12.36.22

Of course this example uses static folder creation, but you can use any dynamic data there in the path property in the JSON data being sent.

Hi Teodor,

Where are you getting this bit from:

{
"metadata": {
"name": "math",
"path_lower": "/homework/math",
"path_display": "/Homework/math",
"id": "id:K6FuXcBNgM8AAAAAAAAADQ"
}
}

I don't understand what you mean by: 'You can get the reponse from the docs'

From dropbox docs:

See the screenshot above.
Defining a schema is not needed for the API call to work, the schema is used in the data picker, so that you can use the info returned from the API in the next steps, for example:

I have no idea then... The text in the Dropbox return is way longer than what you posted so did you edit yours or something, and if I don't use the define api schema what do I do?

All I want to do is to be able to collect some data from a form and use it to create folder in Dropbox, wuld you be able to create tutial or video for me please?

Sorry i don't understand what you mean here.
I already explained you how to use the define schema and provided you the json you need to paste there.

We can't create a tutorial for every single API out there. The basics are already explained, you just follow the docs of the API.
Simply use the dynamic data picker add the dynamic data you need there ...

Thank you Teodor,

I finally figure out what I needed to do by trial and error and the details you gave.

One issue I'm now faced with is the access_token which expires very quickly, I need to work out how best to update token in the Authorization header each time the API action run, any idea?

The access token you generate in you app settings is a short lived token, which is only used for testing. Depending on what will you app do, you need to follow the instructions in the dropbox API docs. A good explanation/starting point is:

Hi Teodor,

The DropBox OAuth2 can present the token I need in a URL, how would I grab that token string from the URL an place it into a hidden input in my form which I can then grab in the API action?

You should never deal with access tokens on the front end. This must all happen in the back end - in the server connect.
You need a refresh token from dropbox, from what i read in the docs the refresh token does not expire. Once you have it, you can get access token which is then used in the API call for creating the folder. The access token lasts for 4 hours. You can just edit your server action to request a new access token every time you user submits the form.
So the server action can be built this way: use refresh token to call access token endpoint > get access token > with the access token call create the folder

Has anyone else in the community does this, sounds even more complicated than just getting the API to work?