C# 无法使用graph sdk在sharepoint online中创建新列表
我已从我的网站备份了该列表,并从中删除了一些列表。 现在我想恢复网站内的列表 为了还原列表,我使用了CREATELIST graph CALL,因为该列表已被删除,并传递了我备份的列表中的所有数据(不包括名称属性) 我作为参数传递的列表是:C# 无法使用graph sdk在sharepoint online中创建新列表,c#,microsoft-graph-api,sharepoint-online,microsoft-graph-sdks,C#,Microsoft Graph Api,Sharepoint Online,Microsoft Graph Sdks,我已从我的网站备份了该列表,并从中删除了一些列表。 现在我想恢复网站内的列表 为了还原列表,我使用了CREATELIST graph CALL,因为该列表已被删除,并传递了我备份的列表中的所有数据(不包括名称属性) 我作为参数传递的列表是: displayName : "qwerty" list columns contentTypes createdBy createdDateTime : "2019-08-07T15:26:45+05:30" description : "" eTag :
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;
我希望输出成功,但graph返回一个或多个错误,其中包含内部错误,因为无法确定提供的列定义的类型您需要按如下方式格式化站点列表
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"
}
};
列定义可能在变量列中-也许您可以发布该变量的值?如Paul所述,如果不清楚columns属性包含的内容,很难回答此问题。请参考此列定义,如果我想创建包含所有列的新列表,将使用此列定义。但我想根据我之前备份的数据创建列表。你不能只使用你提取的数据。该数据将具有大量只读属性id、etag等。。您需要访问数据,填充一个新的列表对象,并将其传递给Graph。同意Marc的回复,您需要首先从备份数据中获取数据,然后将数据传递给Graph中的一个新列表对象。
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);