无法更新文件库 [英] Can't Update a Document library

查看:204
本文介绍了无法更新文件库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MS Graph SDK for .NET CORE,可以很好地创建文档库. 新的库具有允许管理内容类型吗?"是的 但是我无法更改内容类型和显示名称.

Using the MS Graph SDK for .NET CORE, Creating a document library works fine. The new Library has the "Allow management of content types?" as yes But I can't change the content types and the Display name.

在下面的代码上,库已创建,但我可以进行任何更新. 最后一行错误: 代码:-1,Microsoft.SharePoint.Client.InvalidClientQueryException 消息:无效的请求. 内部错误: 附加数据: 请求编号:8e38aeac-39fb-4e59-b3eb-2280a353753a 日期:10/21/2019 9:21:09 PM ClientRequestId:8e38aeac-39fb-4e59-b3eb-2280a353753a

On the code below, the library is created but I can do update to anything. the last line errors with : Code: -1, Microsoft.SharePoint.Client.InvalidClientQueryException Message: Invalid request. Inner error: AdditionalData: request-id: 8e38aeac-39fb-4e59-b3eb-2280a353753a date: 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)"提示它做了一个补丁",所以我用了它.

I did not find any good documentation for applying content types to a List or Library. The "UpdateAsync(uplist)" hinted it does a "Patch" so I used it.

是否有更好的方法来应用内容类型. 我尝试使用Drive,但它没有ContentTypes属性. 感谢您的提示.

Is there a better way to apply content types. I tried with Drive but it does not have a ContentTypes property. Thanks for any hint.

推荐答案

如果仔细查看MS Graph文档,您会注意到不支持更新列表-仅更新列出项目.

If you look closely at the MS Graph documentation, you will notice that updating a list is not supported -- only updating list items.

您可能需要使用旧版SharePoint API( https://docs.microsoft.com /en-us/sharepoint/dev/declarative-customization/site-design-json-schema#addcontenttype )

You will likely need to use the legacy 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) or a Site Script (https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-json-schema#addcontenttype)

这篇关于无法更新文件库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆