cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rjhale
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
v-bacao-msft
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
v-bacao-msft
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

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. 

 

 

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 .

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

Thank you Very Much.

 

It helped a lot

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (60,780)