So, you are trying to do two things at once:
- Get the Item Count for the given folder
- Get the 'fileType' column for all items in the folder
This seems like a job better suited to multiple sequential REST calls, but this worked for me:
<server>/_api/web/GetFolderByServerRelativeUrl('/Pages')?$expand=Folders,Files/ListItemAllFields/FieldValuesAsText&$select=ItemCount,Folders/ItemCount,Folders/Name,Files/ListItemAllFields/FieldValuesAsText/File_x005f_x0020_x005f_Type,Files/ListItemAllFields/FieldValuesAsText/fileLeafRef
Here I'm doing multiple levels of expansion and selection:
$expand=Folders,Files/ListItemAllFields/FieldValuesAsText
- The additional expansion on Files was just to get to the
File_x005f_x0020_x005f_Type
value for each file, which is the same as the file extension
$select=ItemCount,Folders/ItemCount,Folders/Name,Files/ListItemAllFields/FieldValuesAsText/File_x005f_x0020_x005f_Type,Files/ListItemAllFields/FieldValuesAsText/fileLeafRef
- This selects
ItemCount
for the current folder (the folder you specified in GetFolderByServerRelativeUrl
), ItemCount
and Name
for each sub-folder, and File_x005f_x0020_x005f_Type
and fileLeafRef
(the literal file name) for all files contained in the current folder, regardless of sub-folders.
Since this query goes several levels deep, it returns a lot of metadata that you probably don't need. So I would recommend using the odata=nometadata
headers when making your REST call:
Accept:application/json;odata=nometadata
Content-Type:application/json;odata=nometadata
Edit: If I recall correctly, the nometadata
property only works with SP 2016+
fileType
a custom column that you added, or a default column?