3

I'm new to the SharePoint REST API. I have a document library with a lot of documents in it and a lot of metadata fields for those documents. I want to filter and display the items in the library the same way you would with a list using the SharePoint REST API. I can't seem to find how to do that in the Microsoft Dev Center.

I tried the following REST call, and it doesn't return an error but it doesn't seem to return any data either. /_api/Web/Lists/GetByTitle('DocumentLibraryTitle')/items

Anybody know how to do this?

  • a document library essentially is a list. – Mike May 19 '17 at 18:55
0

That call is correct, did you check the result in a navigator? That should return a JSON. Just to be sure, your call should be

$.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('List Nam')/items",
    method: "GET",
    headers: { "accept": "application/json;odata=verbose", },
    success: function (data) {
        console.log(data.d.results);
    },
    error: function (data) {
        console.log(data);
    }
});

enter image description here

  • I've been testing calls in the browser (just through the URL). I was expecting to see the results displayed there. I'm waiting for my IT department to install Fiddler so I can see the results through that. Thanks confirming it for though. – Jason May 19 '17 at 18:58
  • I recomend you chrome to test rest calls, IE is quite an idiot and you have to configure some stuff to see it – Marco May 19 '17 at 18:59
  • Yes, go to your IE Tools -> Content and turn on feed reading view from the Feed and Web Slice Settings. – Mike May 19 '17 at 19:01
  • I've got feed reading turned on in IE, but all I'm seeing is this: imgur.com/a/bVrn5 – Jason May 19 '17 at 19:35
0

PS. Code before Play will take you ages..

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.