3

Currently I am using REST in order to get item titles in the Pages directory. The problem is that it is pulling all the elements that are in the pages directory and I only want it to pull from a certain subfolder in the pages directory.

var moduleServiceUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('Pages')/Items?$select=ID,Title,FileRef,Modules";

This is what the call currently looks like.

6

Try to use this endpoint GetFolderByServerRelativeUrl to return all files and folder at a specific folder URL

https://server/_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Folders,Files

To return only all files at a specific folder URL

https://server/_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Files

For more details check get all the files and folders contained inside a SharePoint folder in one rest API call.

Also if you need work with CSOM check How to get all the files inside the folder in list

  • It only retrieves the first 100 and includes a link to "next 100" Is there any way to pull everything in the list without pagination? – Si8 Mar 22 '17 at 16:00
  • Add to your url the parameter: &$top=1000 – Oskar Apr 5 '18 at 6:57
1

The query you are using will return all items irrespective of type (folder/file). You can use change to below syntax.

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

Example for folder relative path is

/[subsite]/<<library name>>/<<folder name>>
0

I don't fully understand what you need but in order to get attributes of a subfolder you need to access the folder first through this endpoint GetFolderByServerRelativeUrl.

Here is a Microsoft documentation regarding Files and folders REST API call.

0
_spPageContextInfo.webAbsoluteUrl + "/_api/Lists/getbyTitle('" + LibraryName + "')/Items?$select=FileLeafRef,FileRef,Id&$top=5000

This URL will Resolve ur all problems

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.