gpt4 book ai didi

c# - "Already Exists"使用 CSOM 获取 SharePoint 2013 库项目时引发异常

转载 作者:太空宇宙 更新时间:2023-11-03 13:04:34 25 4
gpt4 key购买 nike

我正在尝试使用 C# 中的 CSOM 从 SharePoint 2013 视频 Assets 库中检索所有项目。当我运行我的控制台应用程序时,我偶尔会收到以下错误:

Microsoft.SharePoint.Client.ServerException: A list, survey, discussion board, or document library with the specified title already exists in this Web site.  Please choose another title.

我搜索了错误,但我发现的问题与创建列表或更新项目有关。我只是想找回元素。该库在浏览器中加载得很好。此外,我有一个网页运行与我的控制台应用程序相同的代码并且不会引发异常。这是抛出异常的代码块:

ClientContext context = new ClientContext(SharePointURL);

List AssetList = context.Web.Lists.GetByTitle(SharePointListTitle);

context.Load(AssetList);

CamlQuery query = CamlQuery.CreateAllItemsQuery();
ListItemCollection items = AssetList.GetItems(query);

//Retrieve all items in the ListItemCollection from List.GetItems(Query).
context.Load(items,
itms => itms.Include(
i => i["GUID"],
i => i["Title"],
i => i["FileLeafRef"],
i => i["FileRef"],
i => i["VideoSetDescription"],
i => i["Live_x0020_Date"],
i => i["Expiration_x0020_Date0"],
i => i["Is_x0020_Active"],
i => i["Tags"],
i => i["AlternateThumbnailUrl"]
)
);

context.ExecuteQuery();

最佳答案

我现在在移动设备上,所以我不能轻易地为你测试这个,但我相信你需要在加载 AssetList 后执行 context.ExecuteQuery()

这将使您的来源:

ClientContext context = new ClientContext(SharePointURL);

List AssetList = context.Web.Lists.GetByTitle(SharePointListTitle);

context.Load(AssetList);
context.ExecuteQuery();

CamlQuery query = CamlQuery.CreateAllItemsQuery();
ListItemCollection items = AssetList.GetItems(query);

//Retrieve all items in the ListItemCollection from List.GetItems(Query).
context.Load(items,
itms => itms.Include(
i => i["GUID"],
i => i["Title"],
i => i["FileLeafRef"],
i => i["FileRef"],
i => i["VideoSetDescription"],
i => i["Live_x0020_Date"],
i => i["Expiration_x0020_Date0"],
i => i["Is_x0020_Active"],
i => i["Tags"],
i => i["AlternateThumbnailUrl"]
)
);

context.ExecuteQuery();

如果不是这种情况,请告诉我,我将启动一个项目,我在桌面上做过类似的事情。

关于c# - "Already Exists"使用 CSOM 获取 SharePoint 2013 库项目时引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31183088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com