Jquery 通过RESTAPI在sharepoint中搜索文本
我试图在我的shraepoint中搜索查询文本,但没有成功。 这就是我所尝试的:Jquery 通过RESTAPI在sharepoint中搜索文本,jquery,rest,sharepoint,Jquery,Rest,Sharepoint,我试图在我的shraepoint中搜索查询文本,但没有成功。 这就是我所尝试的: function search(searchQuery) { searchQuery = encodeURIComponent("'" + searchQuery + "'"); var url = 'https://****.sharepoint.com/_api/search/query?querytext=' + searchQuery; $.ajax({ url:
function search(searchQuery) {
searchQuery = encodeURIComponent("'" + searchQuery + "'");
var url = 'https://****.sharepoint.com/_api/search/query?querytext=' + searchQuery;
$.ajax({
url: url,
headers: {
"accept": "application/json;odata=nometadata",
},
method: "GET",
success: function (data) {
console.log(data);
},
error: function (jqxr, errorCode, errorThrown) {
console.log(jqxr);
}
});
}
我在控制台中看到错误403:
{"odata.error":{"code":"-2147024891, System.UnauthorizedAccessException"
我能做什么?
当我输入url时,它工作正常,它给了我xml
tnx您需要在SharePoint站点中运行脚本,以便请求将使用当前用户凭据调用search rest api