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?

Related questions 2 Pulling Excel.xlsx workbook from Sharepoint site using Microsoft Graph API 0 0 Byte file when uploading an Excel document to SharePoint online using the Microsoft Graph API 2 How to overwrite a file uploading to SharePoint with Microsoft Graph Related questions 2 Pulling Excel.xlsx workbook from Sharepoint site using Microsoft Graph API 0 0 Byte file when uploading an Excel document to SharePoint online using the Microsoft Graph API 2 How to overwrite a file uploading to SharePoint with Microsoft Graph 4 Opening Excel file stored on SharePoint as data source using ADODB Connection 0 Read Excel file from Sharepoint using Python 20 Open an Excel file from SharePoint site 1 Reading excel files from sharepoint folder in R 2 How to access Excel Data stored in Sharepoint Online Document Library using Excel Rest API in a Sharepoint Framework (SPFx) app? 0 Unable to Open Copied SharePoint Online File via SSIS 2 Import Excel file located in SharePoint Server into SSIS Load 7 more related questions Show fewer related questions

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.