microsoft-graph-api - 无法更新文档库
问题描述
使用适用于 .NET CORE 的 MS Graph SDK,创建文档库可以正常工作。新图书馆具有“允许管理内容类型?” 是的,但我无法更改内容类型和显示名称。
在下面的代码中,创建了库,但我可以对任何内容进行更新。最后一行错误:代码:-1,Microsoft.SharePoint.Client.InvalidClientQueryException 消息:无效请求。内部错误:AdditionalData:request-id:8e38aeac-39fb-4e59-b3eb-2280a353753a 日期:10/21/2019 9:21:09 PM ClientRequestId:8e38aeac-39fb-4e59-b3eb-2280a353753a
List list = new List
{
ListInfo = rootList.ListInfo,
DisplayName = rootList.Name,
Description = rootList.Description,
};
List newList = await graphClient.Groups[project.GroupID].Sites["root"].Lists.Request().AddAsync(list); // This line works
_log.LogInformation("newList.Id = " + newList.Id); //Gets a new Guid
List uplist = new List
{
Description = "Bla bla" //Or anything
};
List updList = await graphClient.Groups[project.GroupID].Sites["root"].Lists[newList.Id].Request().UpdateAsync(uplist); // This line Fails
我没有找到将内容类型应用于列表或库的任何好的文档。“UpdateAsync(uplist)”暗示它做了一个“补丁”,所以我使用了它。
有没有更好的方法来应用内容类型。我尝试使用 Drive,但它没有 ContentTypes 属性。感谢您的任何提示。
解决方案
如果您仔细查看 MS Graph 文档,您会注意到不支持更新列表- 仅更新列表项。
您可能需要使用旧版 SharePoint API ( https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-rest ?redirectedfrom=MSDN#working-with-lists-by-using-rest)或站点脚本(https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-json-架构#addcontenttype )
推荐阅读
- sqlite - 将新的 CSV 数据插入 sqlite 数据库
- javascript - 针对输入表单中输入的内容分别弹出不同的表单
- php - Gmail 在 WordPress 中显示用于注册、忘记密码或任何其他电子邮件的可疑链接提示
- javascript - 我想将 javascript 中的数据和文件发送到控制器(但如何)(Mvc asp.net)
- javascript - JavaScript 如何访问在它使用的函数之外声明的变量?
- javascript - 仅允许使用正则表达式和字符串替换在 HTML / Javascript 中输入 1-12 和 00-59
- python - 熊猫数据框以一种很好的方式处理“列表”元素
- c# - 如何使用 Nexmo 服务制作语音通话网络应用程序?
- python - 是什么导致这些物体与 pymunk 一起向左飞?
- javascript - 复制 document.write 行为