Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Jeff B.63's avatar
Jeff B.63
Collaborator | Level 9
4 years ago

Can I configure an HTTP action in Logic Apps to delete folders in our company Dropbox account?

I have built a logic app that moves files into temporary folders until all associated files are ready.  Then another logic app moves them to their permanent location. This is because of the 20 item limit on the 'List files' action.  I then created a logic app that finds the empty folders with the purpose of deleting them.  I was trying to use the 'Delete file' action because I thought maybe it would work for folders as well but unfortunately, I keep getting a 'Bad Request' error .  When I look at the output, it says that the error is because it is not a file.

 

Digging deeper, I found the developer site here and was looking at the Http requests and wondered  how I would be able to use this in an Http call from within the logic app.  I have a loop that delivers the path and id of the folders to be deleted.  I am a novice to all of this and I am uncertain of how to properly format the input of the Http request.

 

The Method would be POST

The URI would be 

https://api.dropboxapi.com/2/files/delete_v2

One header would be 

 

 

"Content-Type: application/json" 

 

 

I assume the Body would be the id or path of the folder I want to delete? In JSON like this of course

 

 

{\"path\": \"/Homework/math/quiz\"}"

 

 

Do I need to add authentication?  If so, where would I get the token?  My logic app already has been authorized to access Dropbox so is there a need for more authentication?  There is a box to enter authentication of different kinds but not sure what values to use.

5 Replies

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    4 years ago

    Hi Jeff B.63,

    The best way to check commands format is API explorer, I think. Just select the access point you want to explore and fill the proper parameters. Click "show code" and select "HTTP request". That's it.

    By the way you can use "list_folder/continue" after "list_folder" to see entire folder content in case of big folder. 😉

    Hope this gives direction.

  • Jeff B.63's avatar
    Jeff B.63
    Collaborator | Level 9
    4 years ago

    That is very helpful, thank you.   Do I just use the token created here or do I need a different one?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    Jeff B.63 As Здравко said, the API v2 Explorer is a good tool for building and understanding how to format Dropbox API v2 requests. You can also find specific information regarding each route in the API documentation.

     

    And yes, in addition to the portions you already mentioned, to make an API call like that you need to include authorization, which can be done by supplying an "Authorization" header containing a "Bearer" value with an access token. Check out the OAuth Guide and authorization documentation for information on how that works.

     

    It sounds like you're working from an existing third party app. If there's already an access token and/or refresh token there for the integration that you can access, you could use that. Otherwise, you'd need to use the OAuth flow to get one.

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    4 years ago

    Short lived token is valid for 4 hours only! If that works for you... Ok. I don't know how you are using API, but most probably you can continue in the same way about the token. 😉

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!