0

My REST URL The problem is that when i use author and employee location togther rest url is not formed.

REST URL

/_api/web/lists/getByTitle('Ventile')/items$select=Name,LastDatePUCDone,IsTerminated,Author/Title&$expand=Author/ID,EmployeeLocation/Title&$expand=EmployeeLocation

Code:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script><script>
var spApp=angular.module('spApp',[]);
spApp.controller('spListCtrl',function($scope,$http){
$http(
{
    method: "GET",
    url:"/_api/web/lists/getByTitle('Ventile')/items?$select=Name,LastDatePUCDone,IsTerminated,Author/Title&$expand=Author/ID",
    headers:{"Accept":"application/json;odata=verbose"}
}
).success(function(data,status,headers,config){
    $scope.xData=data.d.results;
    console.log(data.d.results);
}).error(function(data,status,headers,config){

});
});
</script>
<div ng-app="spApp">
<div ng-controller="spListCtrl">
<p><input type="text" ng-model="search"></p>
<table witdh="100%" cellpadding="5" cellspacing="5">
<thead>
<tr>
<th>Name</th>
<th>PUC Date</th>
<th>Is Terminated</th>
<th>Author</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in xData | filter : search">
<td>{{x.Name}}</td>
<td>{{x.LastDatePUCDone}}</td>
<td>{{x.IsTerminated}}</td>
<td>{{x.Author.Title}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</html>
1

In order to use EmployeeLocation, you must have it in your $select list, also, you can't have $expand in there twice.

Right:

/_api/web/lists/getByTitle('Ventile')/items$select=Name,LastDatePUCDone,IsTerminated,Author/Title,EmployeeLocation/Title&$expand=Author/Title,EmployeeLocation/Title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.