[英]How can i replace a file in Onedrive USING THE Graph Api?
I have a fie that already exists in a Onedrive directory , filename is TestFile.txt我有一个已经存在于 Onedrive 目录中的文件,文件名为 TestFile.txt
If i try to move a file with the same name to that directory it gives the error如果我尝试将具有相同名称的文件移动到该目录,则会出现错误
{"error":{"code":"nameAlreadyExists","message":"Name already exists",
I am copying the file to the destination folder as follows我将文件复制到目标文件夹如下
I setup a Patch request to th endpoint /me/drive/items/{Id}我向端点 /me/drive/items/{Id} 设置了一个补丁请求
set the body and send the request.设置正文并发送请求。
var filebody = new { parentReference = new { id = folderDestId }, name = fileName };
request.AddJsonBody(filebody);
var response = client.Execute(request);
But the file is not moved to the new locaion and it doesnt replace the existing file there.但是该文件不会移动到新位置,也不会替换那里的现有文件。
Do i need to delete the file first and then move , or is there something the body I can send to make it automatically replace the file ?我需要先删除文件然后再移动,还是我可以发送正文以使其自动替换文件?
When uploading your file, there is an instance attribute called " conflictBehavior " that you can set to "replace" to achieve that.上传文件时,有一个名为“ conflictBehavior ”的实例属性,您可以将其设置为“替换”以实现该目的。 Note that this is an instance attribute and should be included in the URL instead of the request body.
请注意,这是一个实例属性,应包含在 URL 中而不是请求正文中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.