如何在onedriveAPI的请求正文中指定@ microsoft.graph.conflictBehavior

编程入门 行业动态 更新时间:2024-10-28 12:30:06
本文介绍了如何在onedriveAPI的请求正文中指定@ microsoft.graph.conflictBehavior的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在满足以下要求的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

    本文发布于:2023-10-29 07:35:37,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1539097.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:文中   如何在   onedriveAPI   conflictBehavior   microsoft

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!