I'm trying to delete a file in a document library (SharePoint online) via the Graph SDK
await client
.Drives[driveId]
.Items[sourceItemId]
.Request()
.DeleteAsync();
This work. But if the file is open it'll throw this error:
Status Code: Locked
Microsoft.Graph.ServiceException: Code: resourceLocked
Message: The resource you are attempting to access is locked
How do I force it to delete anyway?
If I try to delete the open file via the SharePoint online UI (browser) then I get a popup saying it's locked but I can choose to delete it anyway. So deleting locked/open files is possible. They just forgot to document it here https://learn.microsoft.com/en-us/graph/api/driveitem-delete?view=graph-rest-1.0&tabs=csharp