【问题标题】:Can't Update a Document library无法更新文档库
【发布时间】:2019-10-21 21:47:46
【问题描述】:

使用适用于 .NET CORE 的 MS Graph SDK,创建文档库可以正常工作。 新图书馆具有“允许管理内容类型?”是的 但我无法更改内容类型和显示名称。

在下面的代码中,库已创建,但我可以对任何内容进行更新。 最后一行错误: 代码:-1,Microsoft.SharePoint.Client.InvalidClientQueryException 消息:无效请求。 内部错误: 附加数据: 请求 ID:8e38aeac-39fb-4e59-b3eb-2280a353753a 日期:2019 年 10 月 21 日晚上 9:21:09 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 属性。 感谢您的任何提示。

【问题讨论】:

    标签: microsoft-graph-api microsoft-graph-sdks


    【解决方案1】:

    【讨论】:

    • 谢谢保罗。你的链接很棒。我只是在使用 .NET Core 2.2 获取 accessToken 时遇到问题。我正在使用“RESTSharp”,它有一些关于 auth2.0 但我无法使用我的 clientID 和客户端密码(来自 SharePoint,而不是像 Graph 一样的 Azure)你知道可以帮助我做到这一点的资源吗?任何提示可能会有所帮助:-) 再次感谢
    • 我不知道 RESTSharp 是什么。但是,您可以将 AAD 中的令牌用于 SharePoint。只需使用 SharePoint 域作为范围。 Graph.Community 库中有一个例子:github.com/microsoftgraph/msgraph-sdk-dotnet-contrib/blob/…
    猜你喜欢
    • 2019-09-13
    • 2020-09-26
    • 1970-01-01
    • 2012-04-05
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多