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?

1
  • a document library essentially is a list.
    – Mike
    Commented May 19, 2017 at 18:55

2 Answers 2

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

4
  • 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
    Commented May 19, 2017 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
    Commented May 19, 2017 at 18:59
  • Yes, go to your IE Tools -> Content and turn on feed reading view from the Feed and Web Slice Settings.
    – Mike
    Commented May 19, 2017 at 19:01
  • I've got feed reading turned on in IE, but all I'm seeing is this: imgur.com/a/bVrn5
    – Jason
    Commented May 19, 2017 at 19:35
0

PS. Code before Play will take you ages..

0

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.