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

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"

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.