I'm trying to connect my AngularJS App to a Sharepoint 2010 List.
I've tried this and this tutorial but neither work for me. Those 2 tutorials are using SharePoint 2013.
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?
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?
Thanks and greetings, Michael
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.
In the 2010 API, to get list data, your URL might be something like:
Where
Steckbrief_Data
is the list whose data you want andhttp://yourserver/yoursite/
is the path to the site where the list resides.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 ofSteckbrief_Data
Read more detailed information here