Power Automate Flow: force a file deletion and force a file replacement

To force a file to be deleted in a SharePoint Document Library, using a Power Automate Flow, we can call the action “Send an HTTP Request to SharePoint“, with the below:

  • Method: POST
  • Uri: _api/web/Lists/GetByTitle(‘Document Library Name’)/GetItemById(@{variables(‘ItemID’)})/recycle
  • Headers: Prefer: bypass-shared-lock

To force a file to be replaced with new content in a SharePoint Document Library, using a Power Automate Flow, we can call the action “Send an HTTP Request to SharePoint“, with the below:

  • Method: POST
  • Uri: _api/web/GetFolderByServerRelativeUrl(‘/sites/SiteCollectionName/SubWebSiteName/’)/Files/add(url=’DestinationFileName.csv’,overwrite=true)
  • Headers: Accept: application/json;odata=nometadata and Content-Type: application/json;odata=nometadata
  • Body: whatever body/content you want

Leave a Reply

Your email address will not be published. Required fields are marked *

*