I'm trying to delete a file in a document library (personal OneDrive) via the Graph SDK (using c#)
await graphClient.Drives[driveId].Items[driveItemId].Request().DeleteAsync();
It works. But if the file is open it'll throw this error:
423 : Locked
....
"error": {
"code": "resourceLocked",
"message": "The resource you are attempting to access is locked",
"innerError": {
"request-id": "d1bfa1f2-cXXXXX",
"date": "2020-05-02T04:05:23"
}
Is there any possibility to check if file is locked/open via Graph API/SDK?)
My current solution is: i make this call
await graphClient.Drives["{driveid}"].Items["{driveItemid}"].Checkout().Request().PostAsync();
In case if file is open i ge t the same 423 error response. Then i ask user to make it close and repeat. In case if i get 204 No content response i make call to delete driveItem.
But i do not think it is an elegant problem solving. Thank you