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 / Use Power Automate to ...
Power Automate
Unanswered

Use Power Automate to permanently delete files from a folder or recycle bin - OneDrive Business

(0) ShareShare
ReportReport
Posted on by 10

I am trying to delete a file from the trash using an HTTP request but I get the following error "{" odata.error ": {" code ":" - 1, Microsoft.SharePoint.Client.InvalidClientQueryException "," message ": {" lang ":" en-US "," value ":" The type SP.RecycleBinItemCollection does not support HTTP DELETE method. "}}}
clientRequestId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx":

 

Immagine.png

is there any other solution to empty the recycle bin or permanently delete a file without going through the first and second level recycle bin?

Categories:
I have the same question (1)
  • Verified answer
    Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @stefanofondaz,

     

    As far as I am aware you cannot use a $filter in that method. You would have to retrieve the id of the item first and use that in a DELETE request.

    https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245382(v=office.15)

     

    Below is an example

     

    GET

    _api/web/RecycleBin?$filter=LeafName eq '@{variables('FileNamewithExtension')}'&$select=Id

     

    DELETE

    _api/web/RecycleBin('@{body('Send_an_HTTP_request_to_SharePoint')['value'][0]['Id']}')

     

     

    deletefromreyclebin_RESTAPI.png

     

     

  • stefanofondaz Profile Picture
    10 on at

    it works!!!!! thank u so much 😍

  • VASYL_MELNYK Profile Picture
    8 on at

    Hi.

     

    https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj246426(v=office.15)

     

    POST http://<sitecollection>/<site>/_api/web/RecycleBin/deleteAll()
    use "Send an HTTP request to SharePoint" for POST
    VASYL_MELNYK_0-1668198051063.png

     

  • AEES Profile Picture
    13 on at

    Hi,
    Could you share the entire PA flow you used? Trying to empty recycle bin like very 5-10 days but cant get it working properly after some test.

  • VictorIvanidze Profile Picture
    13,073 on at

    Show your flow. Do you see any errors?

  • pcamida Profile Picture
    9 on at

    Thanks for the solution! Can someone share the whole flow to copy-paste? I want to delete all items, empty recycle bin without exception. Thank you very much!

     

  • pcamida Profile Picture
    9 on at

    Thank you very much!! It's very simple but it's working. Now, I can empty automatically my recycle bin every day.

  • pcamida Profile Picture
    9 on at

    Any solution for users No Business (no Sharepoint) to empty automatically the recycle bin?

  • ChrisSullivan Profile Picture
    101 on at

    Hi there. 

    This is not working for me. I am trying to delete a list item from the recycle bin after it is delete. 

    I am using 

    "When an Item is Deleted" trigger and the dynamic content "FileNameWithExtention" for the LeafName.

    _api/web/RecycleBin?$filter=LeafName eq'Test delete item from recycle bin if deleted before moving'&$select=Id

    It is not pulling the ID from the Item....?
    Screenshot 2024-03-27 131422.jpg

     

    What might I be doing wrong?

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @ChrisSullivan,


    In the example I shared earlier the query was looking for a file, not a list item. That filter was using the LeafName property.

     

    In your case it is a Title of list item you are using in your filter. In that case try and use the Title property in the filter instead.

     

    _api/web/RecycleBin?$filter=Title eq '@{triggerOutputs()?['body/Name']}'&$select=Id

     

    listitem_deleted.png

     

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard