我正在满足以下要求的C#项目中:
I'm working on a C# project with these requirements:
从Onedrive API文档在OneDrive中创建新文件夹,表示设置@ microsoft.graph.conflictBehavior = rename将增加文件夹值(如果存在)
From Onedrive API documentation Create a new Folder in OneDrive, it says that setting @microsoft.graph.conflictBehavior=rename would increment the folder value if it exists
如何将@ microsoft.graph.conflictBehavior添加到我的请求中?
how can I add the @microsoft.graph.conflictBehavior into my request?
以下是使用驱动器Item创建文件夹的代码
Here's the code which creates the folder using drive Item
var foldertoCreate = new DriveItem { Name = $"TestFolder", Folder = new Folder (), }; var newFolder = await _graphClient.Drive .Items["MyParent_Item_Id"] .Children .Request () .AddAsync (foldertoCreate);推荐答案
我相信您应该可以通过AdditionalData手动添加注释.显然这并不理想,但是我看不到使用当前SDK的另一种方法.
I believe you should be able to add the annotation manually via AdditionalData. Obviously this isn't ideal, but I cannot see another way to do it with the current SDK.
var foldertoCreate = new DriveItem { Name = $"TestFolder", Folder = new Folder(), AdditionalData = new Dictionary<string, object> { { "@microsoft.graph.conflictBehavior", "rename" } }, }; var newFolder = await _graphClient.Drive .Items["MyParent_Item_Id"] .Children .Request() .AddAsync(foldertoCreate);更多推荐
如何在onedriveAPI的请求正文中指定@ microsoft.graph.conflictBehavior
发布评论