"Already Exists" 使用 CSOM 获取 SharePoint 2013 库项目时抛出异常
"Already Exists" Exception thrown when Getting SharePoint 2013 Library items using CSOM
我正在尝试使用 C# 中的 CSOM 从 SharePoint 2013 视频资产库中检索所有项目。当我 运行 我的控制台应用程序时,我偶尔会收到以下错误:
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# 中的 CSOM 从 SharePoint 2013 视频资产库中检索所有项目。当我 运行 我的控制台应用程序时,我偶尔会收到以下错误:
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();
如果不是这种情况,请告诉我,我将启动一个项目,我在桌面上做过类似的事情。