我正在尝试从 sharepoint 2013 在线列表中检索一些项目。我确定列表中有 3 个项目。不知何故,代码不返回任何项目。有谁知道为什么不?在调试 listItems 是空的。
User spUser = null;
SharePointContextToken contextToken;
string accessToken;
Uri sharepointUrl;
string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);
if (contextTokenString != null)
{
contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
var clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
Web web = clientContext.Web;
List list = clientContext.Web.Lists.GetByTitle("CustomListFacturen");
clientContext.Load(list);
CamlQuery query = new CamlQuery();
query.ViewXml = "<View><RowLimit>100</RowLimit></View>";
ListItemCollection listItems = list.GetItems(query);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
if (listItems.Any())
{
ViewBag.Message = "Items are found!!!";
}
}