我最近转向使用.Net Core而不是.Net Framework。我所在的公司要求使用SharePoint列表。
我们使用SharePoint2010。起初,我尝试使用用于.Net Framework的Microsoft.SharePoint.Client dll文件。由于它不适用于.Net Core,因此我从NuGet下载了Microsoft.SharePointOnline.CSOM软件包。
这是我的检索列表的代码(它在.Net Framework中有效,但在.Net代码中无效)
var customerRegions = new List<CustomerRegion>();
ClientContext context = new ClientContext("http://workflowsdev/operations/CustomerManagement");
var SPList = context.Web.Lists.GetByTitle("Customer Regions");
CamlQuery query = new CamlQuery();
ListItemCollection entries = SPList.GetItems(query);
context.Load(entries);
context.ExecuteQuery();
foreach (ListItem currentEntry in entries)
{
var currentRegion = new CustomerRegion();
currentRegion.Region = currentEntry["Region"].ToString();
}
return customerRegions;
代码在context.ExecuteQuery();
处失败
错误:
WebException:远程服务器返回错误:(400)错误的请求。
有人知道如何将其与.Net Core 3.1一起使用吗?我找不到在线解决此问题的任何方法。
当前.netcore不支持csom。在NuGet包中找不到.NET Core兼容。同时,您可以投票给UserVoice一个想法:Support .NET Core with CSOM