簡體   English   中英

無法使用圖sdk在Sharepoint中在線創建新列表

[英]Unable to create a new list in sharepoint online using graph sdk

我已經從網站備份了列表,並從中刪除了一些列表。 現在,我想在網站內恢復列表。

要恢復列表,我使用了create List圖調用(因為刪除了列表),並傳遞了我備份的列表中的所有數據(不包括Name屬性)。

我作為參數傳遞的列表是:

displayName : "qwerty"
list
columns
contentTypes
createdBy
createdDateTime : "2019-08-07T15:26:45+05:30"
description : ""
eTag : ""4aa6af8e-32d6-4ca9-ac0a-02c8e110f65d,6""
lastModifiedDateTime : "2019-08-07T15:26:45+05:30"
name : null
parentReference
webUrl : "https://dextorlab.sharepoint.com/sites/HelloWorld/Lists/qwerty"
id : "4aa6af8e-32d6-4ca9-ac0a-02c8e110f65d"
@odata.etag : ""4aa6af8e-32d6-4ca9-ac0a-02c8e110f65d,6

進行的圖形調用為:

var ListResult = _SharepointOperations._GraphCLient.Sites[_SiteId].Lists.Request().AddAsync(siteList).Result;

我期望輸出成功,但是圖形返回“發生一個或多個錯誤”,內部錯誤為“無法確定提供的列定義的類型”

您需要像下面這樣格式化siteList。

var siteList = new List
{
    DisplayName = "Books",
    Columns = new List<ColumnDefinition>()
    {
        new ColumnDefinition
        {
            Name = "Author",
            Text = new TextColumn
            {
            }
        },
        new ColumnDefinition
        {
            Name = "PageCount",
            Number = new NumberColumn
            {
            }
        }
    },
    List = new ListInfo
    {
        Template = "genericList"
    }
};

文章: 創建一個新列表

使用此將項目添加到列表中。

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var listItem = new ListItem
{
    Fields = new FieldValueSet
    {
        Title = "Widget",
        Color = "Purple",
        Weight = 32
    }
};

await graphClient.Sites["{site-id}"].Lists["{list-id}"].Items
    .Request()
    .AddAsync(listItem);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM