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

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

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

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

Highlighted

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

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

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

Highlighted

Thank you Very Much.

 

It helped a lot

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (9,813)