[英]Do I require permissions to run SPServices on Sharepoint?
I require assistance with Sharepoint. 我需要Sharepoint的帮助。 I've tried multiple ways to retrieve data from a list and have had little to no success, after much reading and searching I'm still no further ahead.
我尝试了多种方法从列表中检索数据,但经过大量阅读和搜索后,我几乎没有成功,甚至没有成功。
I am using a list made by another user, which I can add,edit and delete items from. 我正在使用另一个用户创建的列表,可以在其中添加,编辑和删除项目。 When calling this list using SPServices I seem to hitting a wall.
使用SPServices调用此列表时,我似乎遇到了麻烦。 Here is my third attempt at trying to access the list and now I have received a
404
response and responsetext
is null. 这是我尝试访问列表的第三次尝试,现在我收到了
404
响应,并且responsetext
为null。
The URL is correct, cause it actually loads the list of values. 该URL是正确的,因为它实际上加载了值列表。
If i have an empty webURL parameter, the parameter of responsetext
has a helpful SOAP response stating the following: 如果我有一个空的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>
Here is my call which when I define the webURL to point to the list, it always returns a http 404 with responseText=null
no matter what the url is. 这是我的调用,当我定义webURL指向列表时,无论URL是什么,它始终返回带有
responseText=null
的http 404。 This is not very helpful. 这不是很有帮助。 The Url I am pointing to loads the list.
我要指向的网址会加载列表。
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);
});
}
});
};
I have modified the url each possible way: 我以各种可能的方式修改了网址:
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
Why is this not working??? 为什么这不起作用??? What am I doing wrong???
我究竟做错了什么???
Can you change your implemetation to something other ? 您可以将实现更改为其他内容吗?
Your way is very complicated by my opinion. 我认为您的方法非常复杂。 Third party libraries here are unnecessary.
这里没有第三方库。
Good way is to use out-of-box REST API or JSOM. 好的方法是使用现成的REST API或JSOM。 It is easy to use.
这个用起来很简单。
I see you want to get list item Title field. 我看到您想获取列表项“标题”字段。
Use REST API this way: 通过这种方式使用REST API:
http://site url/_api/web/lists/GetByTitle('Test')/items?$select=Title http:// site url / _api / web / lists / GetByTitle('Test')/ items?$ select = Title
Here you can find example: 在这里您可以找到示例:
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-rest 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 https://www.c-sharpcorner.com/blogs/retrieve-sharepoint-list-items-using-rest-api
May be you can use for SharePoint 2010: 也许可以用于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.