Microsoft Update DriveItem API throwing locked exception if the file is open in desktop

馋奶兔 提交于 2021-01-29 16:24:59

问题


1.This is the behavior I am observing when I use Update DriveItem graph API to update my file name.https://docs.microsoft.com/en-us/graph/api/driveitem-update?view=graph-rest-1.0&tabs=http.

2.If the file is open in my office desktop document it throws locked exception. If i close the file renaming works fine.

3.I tested same in sharepoint their UI ,I am able to rename the file.But through graph API it throws locked exception if file is open.

Is this error expected ?. How can I get around this

https://docs.microsoft.com/en-us/graph/api/driveitem-update?view=graph-rest-1.0&tabs=http.
PATCH https://graph.microsoft.com/v1.0/drives/b!qnfox2pppU-AeWEPhWpRhNiB9gIq_ANJq5NFCiklU2Y5F3fDc7fsaQvB/items/014UHAXWYO5LX2RTA6YZE37E4XTG45PTTW
SdkVersion : graph-java/v1.6.0
Authorization : Bearer
{"name":"V-blah (1) (113_0_4_26).docx"}

423 : Locked
Strict-Transport-Security : max-age=31536000
Cache-Control : private
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"SliceC","Ring":"5","ScaleUnit":"000","RoleInstance":"AGSFE_IN_57"}}
client-request-id : 33f16bde-55d1-XXXX
request-id : XXXXXXX
Content-Length : 251
Date : Sat, 02 May 2020 04:05:23 GMT
Content-Type : application/json
{
  "error": {
    "code": "resourceLocked",
    "message": "The resource you are attempting to access is locked",
    "innerError": {
      "request-id": "d1bfa1f2-cXXXXX",
      "date": "2020-05-02T04:05:23"
    }
  }
}

回答1:


Ensure that the document library does not have "check-in required" enabled.

Assuming check-in is not required, I received the same HTTP 423 "resourceLocked" response for both scenarios: file opened in the browser (SharePoint Online UI) and file opened in desktop client. I believe this is working by design that you can't update a file's name when it is currently opened by another user or yourself in another instance.

Please see this reference about files locked for editing.



来源:https://stackoverflow.com/questions/61554807/microsoft-update-driveitem-api-throwing-locked-exception-if-the-file-is-open-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!