c#-Microsoft Graph API-对DriveItem的权限不起作用
我正在使用Microsoft Graph将c#-Microsoft Graph API-对DriveItem的权限不起作用,c#,microsoft-graph-api,microsoft-graph-sdks,C#,Microsoft Graph Api,Microsoft Graph Sdks,我正在使用Microsoft Graph将DriveItem创建为文件夹,并尝试将权限设置为“替换”。我尝试了以下方法: var driveItem = new DriveItem { Name = Customer_Name.Text + Customer_LName.Text, Folder = new Folder { }, AdditionalData = new Dictionary<string, object>() {
DriveItem
创建为文件夹
,并尝试将权限设置为“替换”。我尝试了以下方法:
var driveItem = new DriveItem
{
Name = Customer_Name.Text + Customer_LName.Text,
Folder = new Folder { },
AdditionalData = new Dictionary<string, object>()
{
{ "@microsoft.graph.conflictBehavior", "replace" }
}
};
var newFolder = await App.GraphClient
.Me
.Drive
.Items["item.ID"]
.Children
.Request()
.AddAsync(driveItem);
var driveItem=新的driveItem
{
Name=Customer\u Name.Text+Customer\u LName.Text,
Folder=新文件夹{},
AdditionalData=新字典()
{
{“@microsoft.graph.conflictBehavior”,“replace”}
}
};
var newFolder=wait App.GraphClient
我
.开车
.Items[“item.ID”]
儿童
.Request()
.AddAsync(驱动项);
第一次运行代码时,一切正常,但第二次出现以下错误:
无法获取文件夹的内容
这太奇怪了…我做错了什么?或者有没有办法通过名称获取驱动项来获取id?文档在这一点上并不清楚,但是
“@microsoft.graph.conflictBehavior”:“replace”
不是文件夹的有效选项。如果您认为“代码> >替换<代码>的含义将在这里,则可能导致任何子文件或文件夹被无意地擦除。
至于使用路径而不是id,可以通过将Item[“id”]
替换为ItemWithPath(“Item/with/path”)
:
您可以使用以下方法检索它的子项:
var childItems = await App.GraphClient
.Me
.Drive
.Root
.ItemWithPath("folder name")
.Children
.Request()
.GetAsync();
var childItems = await App.GraphClient
.Me
.Drive
.Root
.ItemWithPath("folder name")
.Children
.Request()
.GetAsync();