0

Is there a REST way to get all the documents with its properties under a specific folder into a document library ?

I'm doing it like so:

var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/lists/getbytitle('Documents')/items?$select=FileRef,ServerRedirectedEmbedUrl,Title,URL,File&$expand=File";

But it gives me all documents in the lib, I tried filtering fileRef but it doesn´t worked.

So I look for a better way to accomplish that.

Thanks

Emmanuel Villegas
  • 497
  • 4
  • 7
  • 25
  • 2
    check this https://sharepoint.stackexchange.com/questions/138135/get-all-files-and-folders-in-one-call – TARUN Jun 12 '17 at 15:17

1 Answers1

0

You can use following REST query to retrieve the files in a folder.

var url = _spPageContextInfo.webAbsoluteUrl + "_api/web/getfolderbyserverrelativeurl('<<folder path>>')/Files"

Here folder path is your folder relative path.

Example

https://tenant.sharepoint.com/subsite/_api/web/getfolderbyserverrelativeurl('/subsite/Documents')/Files

To include subfolders and files use the following syntax

var url = _spPageContextInfo.webAbsoluteUrl + "_api/web/getfolderbyserverrelativeurl('<<folder path>>')?$expand=Folders,Files"
Venkat Konjeti
  • 4,959
  • 1
  • 10
  • 19