1

Using delete file action the file is deleted but goes to recycle bin.

2 Answers 2

0

You can delete the file(s) permanently using REST API "HTTP DELETE".

$.ajax({  
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfilebyserverrelativeurl('/Shared%20Documents')",  
        type: "POST",  
        contentType: "application/json;odata=verbose",  
        headers: {  
            "Accept": "application/json;odata=verbose",  
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),  
            "IF-MATCH": "*",  
            "X-HTTP-Method": "DELETE",  
        },  
        success: function(data) {  
            alert("success");  
        },  
        error: function(data) {  
            alert("failed");  
        }  
    });  

You can send the items to the Recycle Bin by adding "/recycle()" to the API URL.

A successful Delete returns no data. A successful recycle() returns the GUID for the recycled item.

Reference

4
  • santosh is asking to delete the file using Microsoft flow. Not REST api. Commented Sep 29, 2018 at 13:53
  • I don't know hard delete using MS Flow so I just provided an alternative. Commented Sep 29, 2018 at 14:00
  • @GaneshSanap can we trigger REST API using MS flow else any idea about hard delete file using flow. Commented Oct 1, 2018 at 3:56
  • @santoshkalange actually i have never used REST API in flow. but found one URL about same, here. in sharepoint online, you can use Microsoft Graph too. Commented Oct 1, 2018 at 8:34
0

As Sohail's reply, if you want to permanently delete the file using Microsoft flow, we need call rest api below to achieve it.

url: https://site url/_api/web/GetFileByServerRelativeUrl('/Folder Name/file name')
method: POST
headers:
    Authorization: "Bearer " + accessToken
     X-RequestDigest: form digest value
    IF-MATCH: etag or "*"
    X-HTTP-Method:"DELETE"

Here is an example about how to delete all Subsites using REST API in Flow for your reference.

Microsoft Flow | SharePoint Online | Delete all Subsites using REST API

More information:

HOW TO CALL SHAREPOINT REST WEBSERVICE FROM MICROSOFT FLOW

2
  • Thanks @LZ_MSFT but is there any action in flow which permanent delete the file from document library. Commented Oct 1, 2018 at 7:59
  • It seems not an action in Flow to permanent delete the file from document library, we have to use REST API to achieve it.
    – LZ_MSFT
    Commented Oct 1, 2018 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.