How to delete SharePoint folders using Power Automate

In this post we take a look at how select folders in SharePoint can be deleted using Power Automate

In this post we take a look at how select folders in SharePoint can be deleted using Power Automate.

Intro

A short post this time, but one I wanted to document as it caused me a minor headache in something I was recently building. Folders…there is no easy way to delete select folders from within a flow in Power Automate – no in-built action or anything similar – so once again it is our handy API calls to the rescue!

In researching how others had solved this problem I came across this community thread that held the answer, but my example was a tiny bit different, so follow along as we delete some folders.

The scenario

I have a flow that creates temporary files that are stored in a sub-folder (temp) within a document library in SharePoint. Once the files are created, the flow merges them into a single file and I then need to delete the sub-folder and it’s contents.

The solution

  • In a Power Automate flow add a send a HTTP request to SharePoint action
  • Enter the relevant site address
  • Select DELETE as Method
  • For Uri, enter the following:
_api/web/GetFolderByServerRelativeUrl('/sites/SITENAME/LIBRARYNAME/FOLDERNAME/SUBFOLDERNAME')
  • Leave Headers and Body empty

Your action should look like the following:

Send an HTTP request to SharePoint to delete a folder (or sub-folder).

That’s it! This action will now delete the specified folder when it runs each time.


One response to “How to delete SharePoint folders using Power Automate”

  1. Hi, thank you so much, this solution works well for me!!!

Leave a Reply

Recent posts

Discover more from SharePoint Stuff

Subscribe now to keep reading and get access to the full archive.

Continue reading