restsharepoint-online

&$filter=substringof('ECG Spreadsheet.xlsx',File/Name) errors with "Column 'File' does not exist


Using SharePoint REST

 /_api/web/Lists/getbytitle('DPC Documents')/items?$expand=File&$select=File/Name

Works fine but

/_api/web/Lists/getbytitle('DPC Documents')/items?$expand=File&$select=File/Name&$filter=substringof('ATR Test 7.docx',File/Name)

Shows error:

"odata.error": {
        "code": "-2146232832, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "Column 'File' does not exist. It may have been deleted by another user."
        }

Any explanation? who can I search by file name? Thanks


Solution

  • You can try this:

    /_api/web/Lists/getbytitle('DPC Documents')/items?$expand=File&$select=File/Name&$filter=substringof('ATR Test 7.docx', FileLeafRef)
    

    To filter by the file name, use the FileLeafRef field, which is the internal field name SharePoint uses to represent the file name.