[英]Do I require permissions to run SPServices on Sharepoint?
我需要Sharepoint的幫助。 我嘗試了多種方法從列表中檢索數據,但經過大量閱讀和搜索后,我幾乎沒有成功,甚至沒有成功。
我正在使用另一個用戶創建的列表,可以在其中添加,編輯和刪除項目。 使用SPServices調用此列表時,我似乎遇到了麻煩。 這是我嘗試訪問列表的第三次嘗試,現在我收到了404
響應,並且responsetext
為null。
該URL是正確的,因為它實際上加載了值列表。
如果我有一個空的webURL參數,則responsetext
的參數會有一個有用的SOAP響應,說明以下內容:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">
List does not exist.
The page you selected contains a list that does not exist. It may have been deleted by another user.
</errorstring><errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x82000006</errorcode></detail></soap:Fault></soap:Body></soap:Envelope>
這是我的調用,當我定義webURL指向列表時,無論URL是什么,它始終返回帶有responseText=null
的http 404。 這不是很有幫助。 我要指向的網址會加載列表。
function getListItems_RFC(){
var url = $().SPServices.SPGetCurrentSite() +
"/_vti_bin/listdata.svc/RFCExtract";
console.log("getListItems_RFC() "+ url);
$().SPServices({
operation: "GetListItems",
webURL: url,
async: false,
listName: "RFC Extract",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc:
function (xData, Status) {
console.log(Status); //outputs error
console.log(xData); //outputs array responseText:null and status:404
$(xData.responseXML).SPFilterNode("m:properties").each(function() {
var liHtml = "<li>" + $(this).attr("d:Title") + "</li>";
$("#debug").append(liHtml);
});
}
});
};
我以各種可能的方式修改了網址:
var url = $().SPServices.SPGetCurrentSite() +
"/_vti_bin/listdata.svc/"; //responseText=null, status:404
var url = $().SPServices.SPGetCurrentSite();//responseText=null, status:404
var url = "" //responseText=soapresponse above, status:500
為什么這不起作用??? 我究竟做錯了什么???
您可以將實現更改為其他內容嗎?
我認為您的方法非常復雜。 這里沒有第三方庫。
好的方法是使用現成的REST API或JSOM。 這個用起來很簡單。
我看到您想獲取列表項“標題”字段。
通過這種方式使用REST API:
http:// site url / _api / web / lists / GetByTitle('Test')/ items?$ select = Title
在這里您可以找到示例:
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-rest
https://www.c-sharpcorner.com/blogs/retrieve-sharepoint-list-items-using-rest-api
也許可以用於SharePoint 2010:
var myRestApiUrl = _spPageContextInfo.webServerRelativeUrl + "/_vti_bin/ListData.svc/RFCExtract?$select=Title";
var get = function (url) {
return jQuery.ajax({
url: url,
type: "GET",
processData: false,
headers: {
Accept: "application/json;odata=verbose",
}
});
};
get(myRestApiUrl)
.then(function(response){
// TODO: do actions with response
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.