cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate III
Advocate III

Delete Folder in SharePoint via HTTP Action?

Is it possible to delete a folder in a SharePoint document library via the HTTP Request action?  I've been able to successfully create folders with the HTTP action, but I can't figure out how to use the same functionality to delete empty folders.  

 

Any help working out the syntax would be very much appreciated.  Thank you. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Delete Folder in SharePoint via HTTP Action?

Hi @rjhale,

 

You could try to implement your needs using the existing action of the SharePoint connector.

Use Get files(properties only) to get all the files (including folders).

Configure Filter array to filter out the folders contained in the specified folder.

48.PNG

Use List folder to list the files and folders contained in the folder.

If the length of the output body is equal to 0, then this folder is an empty folder.

This folder can be deleted by configuring the corresponding ID.

Expression:

items('Apply_to_each')['{Identifier}']

length(body('List_folder'))

items('Apply_to_each')['ID']

49.PNG

When doing the test, it is recommended to create new folders and files to avoid accidental deletion of files.

Please take a try.

 

Best Regards,

Barry

 

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Community Support
Community Support

Re: Delete Folder in SharePoint via HTTP Action?

Hi @rjhale,

 

You could try to implement your needs using the existing action of the SharePoint connector.

Use Get files(properties only) to get all the files (including folders).

Configure Filter array to filter out the folders contained in the specified folder.

48.PNG

Use List folder to list the files and folders contained in the folder.

If the length of the output body is equal to 0, then this folder is an empty folder.

This folder can be deleted by configuring the corresponding ID.

Expression:

items('Apply_to_each')['{Identifier}']

length(body('List_folder'))

items('Apply_to_each')['ID']

49.PNG

When doing the test, it is recommended to create new folders and files to avoid accidental deletion of files.

Please take a try.

 

Best Regards,

Barry

 

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Advocate III
Advocate III

Re: Delete Folder in SharePoint via HTTP Action?

Wow. That worked!  The only change I had to make was to use the document library ID in the List Name property of the Delete Item step.  I tried using the name of the document library as a custom value, but I kept getting 404 errors. 

 

Thank you very much for the detailed write up on how to get to the correct solution.  I really appreciate the help. 

 

 

Highlighted
Frequent Visitor

Re: Delete Folder in SharePoint via HTTP Action?

It really work, wow. Although this is an old tread, but there is not a lot of easy answers on how to get it done without using sophisticated methods like HTTP action or other workarounds. Now I can sleep with ease. Thank to @rjhale and @v-bacao-msft .

Highlighted
Regular Visitor

Re: Delete Folder in SharePoint via HTTP Action?

@rjhale thanks for your information.i used your information it is working fine .

Highlighted
New Member

Re: Delete Folder in SharePoint via HTTP Action?

Thank you Very Much.

 

It helped a lot

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (10,761)