PowerAutomate – Sharepoint File Delete

Its the error we all fear, we spent an hour on our flow mapping it out logically and crafting it for the best efficiency; It comes down to the crunch and you get the dredded flow failed.

But wait… that path is correct, infact if you pull that entire URL into the path in your browser MS Word will open a document; So whats going on ? Unlike the documentation, you could follow several blogposts online and find that “Its Bugged” or that you need to go ahead and use a HTTP request to sharepoint in order to delete your file.

It would seem to me to be a bit odd that this type of path does not work, especially as the Create File function works on this relative File Identify format as many folks will know.

 {
  "error": {
    "code": 404,
    "source": "flow-apim-europe-001-francecentral-01.azure-apim.net",
    "clientRequestId": "b4b8df9b-16e4-49e2-84ca-9f25afdbb08e",
    "message": "The response is not in a JSON format.",
    "innerError": "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
  }
} 

There is nothing per say that really jumps out here, however the solution that was advised here was the golden ticket:

https://powerusers.microsoft.com/t5/Building-Flows/SharePoint-Delete-file/m-p/349621/highlight/true#M38559

Conversion of String to URI

The resolution in retrospect is simple, the use of URI would ultimately be the definitive resolution to the issue, it seems that whatever API that is used on Sharepoint Online by PowerAutomate may require this in URI Format. It is however interesting that if you use the manual tree view in the Delete File Flow to find the file and select that it will appear in the UI similar to how our errored flow would delete, with the exception that it will work.

This could be potentially be because the Flow UI is showing us the Display Version of the File Path but in the background is passing a URI.

And thankfully another task automated 🙂