web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Delete locked SharePoi...
Power Automate
Unanswered

Delete locked SharePoint file in doc Library

(1) ShareShare
ReportReport
Posted on by 39
Hello,
 
I have to delete a locked file in one of my document libraries on a SharePoint site. I understand this needs to be done with a 'Send HTTP request to SharePoint' action. However, I don't know exactly what to use for the site or for the Uri to get to the file. 
 
Site address: "http://mySite/sites/ThisSite"
Document Library: "docLib"
File path within the library: "folder/myFile.xlsx"
 
I have tried setting the action's Site Address and Uri to different combinations of the above values, but I am always getting a doc not found error.
 
Using the above locations, how do I set the Site Address and the Uri in the action to actual get to the file and delete it?
Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    A doc not found error may be related to the item having no checked in version. Do you have major and minor versions enabled? If so and you have owner permissions on the site, go to the document library settings and choose Manage files which have no checked in versions. Then check in the files. Run your flow to see if that resolves the issue.
  • KevinBod Profile Picture
    39 on at
    In the Version Settings, I have only Create major versions enabled
     
    I also have no checked out files.
     
    What I really need to know is where to call out the doc library and folder path to the file. Do I append that to the site address, (i.e., Site address/Document Library/File Path) or do I call it out in the Uri (i.e., Document Library/File Path)?
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    Someone else will need to answer your question regarding your HTTP request. Based on the error you mentioned of the document not found, the no checked in version could have been the culprit. But it sounds like you're having trouble configuring the HTTP request to delete an item.
     
    Is there a reason you don't want to use the delete file action, which is what I use and is why I cannot assist with the HTTP request method:
  • KevinBod Profile Picture
    39 on at
    The Delete File action fails for locked files.
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    I think first you will need to figure out why are they are locked as that will determine what you need to do:
    1. You've already ruled out that it is not because the item has no checked in version.
    2. Do you have any label policies in place that prevent files from being deleted?
    3. Do you have in-place records retention and the items are locked because they have been declared a record?
    4. Is the locked file an Excel file that someone has open and is editing? If so, I would ask why would you want to delete a file someone is working on?
    5. Is the file locked because someone has it checked out?
    6. Do you (the owner of the flow) have permissions to delete files?
    7. None of the above.
    Depending on which scenario is the cause of the lock, that will determine what you need to do.
  • KevinBod Profile Picture
    39 on at
    The file is locked because my flow has just recently updated it. 
     
    To fully test my flow, I need to run it multiple times with many different values (100's). This test will be run from a Power App that repeatedly calls the flow. However, on the second call to the flow, the file is locked from the previous operation. Since the lock will remain for up to 6 minutes (according to Google AI), I need to delete it at the beginning of the flow so I can complete the testing in hours instead of in days.
     
    I just need some guidance on how to configure the action. 
    Kevin
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    If the file is locked for the reason you specify, add a delay to your flow before the delete item action to give SharePoint time to release the lock. If you want to get fancy, do this:
    • Create a Boolean variable named deleted and set the default value to false.
    • Put the delete file action inside of a do until action.
    • Configure it to run until "deleted" is true.
    • After the delete file action, add an update variable action and set "deleted" to true.
    • Add a delay action as parallel action below the delete file action and set the delay to 5 minutes (be sure to keep your delay before the do until action as that will be an initial delay to wait for the file to be released from the lock.
    • Configure the delay action to only run if the delete item action fails. This way, the flow will wait another five minutes and try again.
    • By default, the do until action will try this 60 times before it times out and fails. This would give your flow three hours to delete the file. If it is not deleted by then, something else is wrong.
  • KevinBod Profile Picture
    39 on at
    Sure, I can do all the work around, but I really only want to know how to configure the Send HTTP request to SharePoint action and not have the 5-minute wait time and all of the hulabaloo in a work around.
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    As I mentioned earlier, you'll need to wait for someone else to answer as I don't know how to do that since I don't use an HTTP request to delete items. Good luck!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard