Can't Update a Document library

帅比萌擦擦* 提交于 2019-12-13 03:09:44

问题


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.

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 

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.

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.


回答1:


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

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)



来源:https://stackoverflow.com/questions/58494552/cant-update-a-document-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!