It does not seem possible to filter list items using FileSystemObjectType property in SharePoint 2013 REST.
Option 1
But you could utilize the following REST query to return folders and associated list items:
/_api/web/lists/Lists(guid'GUID')/rootFolder/Folders?$expand=ListItemAllFields
JavaScript example
var listTitle = "Documents";
var url = "/_api/web/lists/getByTitle('" + listTitle + "')/rootFolder/Folders?$expand=ListItemAllFields";
$.getJSON(url, function(data) {
//print folders
$(data.value).each(function(i,folder){
var folderName = folder.Name;
var folderItem = folder.ListItemAllFields; //get asssociated List Item with a Folder
});
});
Update
In order to exclude "system" folders like Attachments
you could apply an additional filter like demonstrated below:
/_api/web/lists/getByTitle('list title')/rootFolder/Folders?$expand=ListItemAllFields&$filter=Name ne 'Attachments' and Name ne 'Item' and Name ne 'Forms'
Option 2
Another approach would be to apply the filtering by Folder via CAML query as demonstrated below:
function getListItems(listTitle, queryViewXml)
{
var queryPayload = {
'query':{
'__metadata': { 'type': 'SP.CamlQuery' },
'ViewXml': queryViewXml
}
};
var endpointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getitems";
return $.ajax({
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
data: JSON.stringify(queryPayload),
url: endpointUrl
});
}
function getFolderItems(listTitle)
{
var query = '<View><Query><Where><Eq><FieldRef Name="FSObjType" /><Value Type="Integer">1</Value></Eq></Where></Query></View>';
return getListItems(listTitle,query);
}
Usage
//retrieve and print folder item names
getFolderItems('Requests')
.done(function(data){
var items = data.d.results;
for(var i = 0; i < items.length; i++) {
console.log(items[i].Title);
}
})
.fail(function(error){
console.log(JSON.stringify(error));
});
Option 3
Utilize SharePoint 2010 REST Interface, in particular the following query returns folder items:
/_vti_bin/listdata.svc/Requests?$filter=ContentType eq 'Folder'
where Requests
is the name of a List