我正在处理一个项目,我必须在不存在的情况下在 SharePoint 上创建驱动器(文档库)。
使用以下代码:
var newRRRDrive = new Drive
{
Name = "RRRR-Prod1",
Description = "Holds RRRR files",
AdditionalData = new Dictionary<string, object>()
{
{"@microsoft.graph.conflictBehavior","rename"}
}
};
var newDrive = await graphClient
.Sites[site.Id]
.Drives
.Request()
.AddAsync(newRRRDrive);
但是这是抛出请求无效的异常。我不知道我在这里做错了什么..有什么建议吗?
代码:invalidRequest 消息:无效请求 内部错误: 附加数据: 日期:2021-05-30T20:57:40 请求 ID:ec6ddddddddddddddd0f72d91c8e 客户端请求 ID:ec6dddddddddddddddddddddddddddddddddd ClientRequestId: ec6deddddddddddddddddddddddddddddddddddddddddddd
在 Michael 实现 soln 后添加图像 enter image description here
答案 0 :(得分:0)
要创建新的文档库,您可以执行 create list 中提到的相同调用,而不是使用 genericList 模板值。使用 documentLibrary 值。
POST /sites/{site-id}/lists
Content-Type: application/json
{
"displayName": "YourLibraryName",
"list": {
"template": "documentLibrary"
}
}
C# 代码
var list = new List
{
DisplayName = "Books",
ListInfo = new ListInfo
{
Template = "documentLibrary"
}
};
await graphClient.Sites["{site-id}"].Lists
.Request()
.AddAsync(list);