How to Get List of folders and files in SharePoint Document library using REST API in SharePoint online/Office 365?

Hello SharePointers,

Below is the REST API snippet to find folders and files inside the folder url of a sharepoint document library.

var folderUrl = ‘myfolder/2016’;
var url = _spPageContextInfo.webServerRelativeUrl + “/_api/Web/GetFolderByServerRelativeUrl(‘” + folderUrl + “‘)?$expand=Folders,Files”;


for(var i = 0; i < data.Files.length;i++){

for(var i = 0; i < data.Folders.length;i++){

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *