问题描述
我正在尝试将AngularJS应用程序连接到Sharepoint 2010列表.
I'm trying to connect my AngularJS App to a Sharepoint 2010 List.
我已经尝试过此和本教程,但对我都不起作用.那两个教程使用的是SharePoint 2013.
I've tried this and this tutorial but neither work for me. Those 2 tutorials are using SharePoint 2013.
第一个问题是:"SharePoint 2010是否有RestAPI供我连接?" -如果SP 2010具有此功能,为什么我不能连接列表?
Well the first question is: "Does SharePoint 2010 have a RestAPI for me to connect with?" - If SP 2010 has this feature, why can't I connect with the list?
我的列表称为"Steckbrief_Data",我要运行的代码是:
My list is called "Steckbrief_Data" and the code I'm trying to run is:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http(
{
method: "GET",
url: GetSiteUrl() + "_api/web/lists/getByTitle('Steckbrief_Data')/items"
headers: {"Accept": "application/json;odata=verbose" }
}).success(function (data, status, headers, config) {
alert("success");
$scope.Employees = data.d.results;
}).error(function (data, status, headers, config) {
alert("error");
});
});
function GetSiteUrl() {
var urlParts = document.location.href.split("/");
return urlParts[0] + "//" + urlParts[2] + "/" + urlParts[3] + "/" + urlParts[4];
}
那么你能告诉我这里出了什么问题吗?
So could you tell me what is going wrong here?
谢谢和问候,迈克尔
推荐答案
SharePoint 2010具有REST API,但没有2013年那么广泛.就您而言,"getByTitle"不属于2010 API.
SharePoint 2010 has a REST API, but it isn't as extensive as 2013's. In your case, 'getByTitle' is not part of the 2010 API.
在2010 API中,要获取列表数据,您的URL可能类似于:
In the 2010 API, to get list data, your URL might be something like:
Steckbrief_Data
是要获取其数据的列表,而http://yourserver/yoursite/
是该列表所在站点的路径.
Where Steckbrief_Data
is the list whose data you want and http://yourserver/yoursite/
is the path to the site where the list resides.
如果这不可行,请在浏览器中首先尝试http://yoursever/yoursite/_vti_bin/ListData.svc/
.获取列表的内部名称,并尝试使用它代替Steckbrief_Data
If this doesn't work off the bat, in a browser, try http://yoursever/yoursite/_vti_bin/ListData.svc/
first. Get the internal name of the list and try that in place of Steckbrief_Data
在此处
这篇关于将AngularJS连接到SharePoint 2010列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!