I have a REST query which works as it should in SharePoint 2013 on-premise, but not in SharePoint Online.

The query is as follows (after encoding):


If I remove the filter, I see all my files and folders in the result as expected. As soon as the filter is turned on, I get nothing. I can see from the the result when I don't include the filter that several items have the value I am attempting to filter on. Changing the filter to FileRef eq 'specific value' yields no results either.

Is it not possible to use filter on this field in SharePoint online?


This issue is fixed in April 2018 CU of SharePoint server 2016.

  • Thank you for this info! It really fixes the issue. – Adiu yesterday

Indeed, $filter query option does not seem to be working as expected in SharePoint Online/SharePoint 2016 with at least the following fields:

  • FileRef
  • FileLeafRef
  • FileDirRef

The similar issue has been already reported in User Voice community but unfortunately without any feedback so far.

Meanwhile you could utilize GetItems method to construct a filter expression via CAML query instead of $filter query option as demonstrated below:

function getListItems(webUrl,listTitle, queryText) 
    var viewXml = '<View><Query>' + queryText + '</Query></View>';
    var url = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getitems"; 
    var queryPayload = {  
               'query' : {
                      '__metadata': { 'type': 'SP.CamlQuery' }, 
                      'ViewXml' : viewXml,

    return $.ajax({
           url: url,
           method: "POST",
           data: JSON.stringify(queryPayload),
           headers: {
              "X-RequestDigest": $("#__REQUESTDIGEST").val(),
              "Accept": "application/json; odata=verbose",
              "content-type": "application/json; odata=verbose"


var queryText = '<Where><Contains><FieldRef Name="FileRef"/><Value Type="Url">site/web/library/folder</Value></Contains></Where>';

getListItems(_spPageContextInfo.webAbsoluteUrl,listTitle, queryText)
     var items = data.d.results;
     for(var i = 0; i < items.length;i++) {

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.