I am trying to retrieve list . I used below code

        method: 'GET',
        url: _spPageContextInfo.webAbsoluteUrl + "/Lists/MyList",
        headers: { "Accept": "application/json;odata=verbose" }
    }).success(function (data, status, headers, config) {
        $scope.customers = data.d.results;
    }).error(function (data, status, headers, config) {


But when code executes i get wiered data in data variable. I get information of whole page which is all html. What am i doing wrong?

  • I am getting the below error. can some one help me. Error: $injector:modulerr Module Error Commented Aug 8, 2018 at 10:32

1 Answer 1


That is because you are not calling the REST api "/_api/web/lists/getByTitle('MyList')", the url you are calling returns the the ListView (AllItems.aspx) page. Change the url to _spPageContextInfo.webAbsoluteUrl + '/_api/web/lists/getByTitle("MyList")/items'

  • ok now i am not getting wiered data. But i get undefined when i do data.d.results
    – Happy
    Commented Sep 9, 2015 at 8:42
  • are you trying to load list items or list properties? the endpoint for listitems is "_spPageContextInfo.webAbsoluteUrl + '/_api/web/lists/getByTitle("MyList")/items Commented Sep 9, 2015 at 8:43
  • just a last question. What if i wanted to retrieve item based on some criteria?
    – Happy
    Commented Sep 9, 2015 at 8:53
  • you can use the $filter url parameters to filter the data based on a condition(similar to CAML conditions), there are many parameters you can use with REST, here are the operators and usage. msdn.microsoft.com/en-us/library/office/fp142385.aspx and adicodes.com/… Commented Sep 9, 2015 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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