我需要调用Intranet SharePoint 2016 REST API来检索项目。我的选择是CSOM(或JSOM)或REST API。我计划使用需要访问令牌的REST API。我查看了文档,但似乎没有什么简单明了。是否有人对我如何每次都不要求用户提供凭据的访问令牌提出建议。
此外,我试图获取在后续检查之间已上载的新文档的列表。有没有办法做到这一点?考虑差异更新与完整更新。
答案 0 :(得分:2)
您可以通过执行以下POST请求来获取SharePoint 2016表单摘要值:
$.ajax
({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/contextinfo",
type: "POST",
async: false,
headers: { "accept": "application/json;odata=verbose" },
success: function(data){
var FormDigestValue = data.d.GetContextWebInformation.FormDigestValue;
console.log(FormDigestValue);
},
error: function (xhr, status, error)
{
console.log("Failed");
}
});
然后在使用Rest API连接到SharePoint时,在ajax请求标头中使用此摘要值:
参考:
Get Form Digest Value in SharePoint using REST API
SharePoint – How to Authenticate SharePoint REST APIs with REST Client