0

I am trying to replace an Excel file on Microsoft SharePoint with another local file using R and the Microsoft365R package. The issue arises when the Excel file on SharePoint is open online by another user, which results in an error when attempting to delete it. I receive the following error message: "Locked (WebDAV; RFC 4918) (HTTP 423). Failed to complete operation. Message: The resource you are attempting to access is locked."

Here is the code I am currently using to delete and upload the file:

drv <- site$get_drive("My_drive")
drv$delete_item("Share_prova/mesos.xlsx", confirm = FALSE)
drv$upload_file("mesos.xlsx", dest = "Compartir_prova/mesos.xlsx")

Attempted Solutions:

  • I have tried using the Microsoft Graph API package to obtain the lock status of a file on SharePoint before deleting it, but I haven't been able to find a suitable solution.
  • I have also researched other functions or methods in the Microsoft365R package that might facilitate replacing a locked file, but I haven't found any relevant documentation.

Specific Question:

  • How can I check the lock status of a file on Microsoft SharePoint before attempting to delete it using the Microsoft365R package in R?
  • Is there a more elegant way to replace a file on SharePoint without encountering the locked file error?
Marc
  • 1

0 Answers0