I am trying to filter the files in a document library folder by file type and using the below API call for it. But the filtering doesn't work and it returns files with all the file types regardless of the file type filter used.

http://sharepointUrl/_api/Web/GetFolderByServerRelativeUrl('/Shared%20Documents/garima')?$expand=Folders,Files/ListItemAllFields/FieldValuesAsText&$filter=(Files/ListItemAllFields/FieldValuesAsText/File_x005f_x0020_x005f_Type eq 'xlsx')

I am able to filter by file type in office 365 using the field ListItemAllFields/File_x0020_Type.

Can someone tell if the filtering by file type is allowed for on-premises SharePoint? If yes, what is the correct way to do it.

  • Is "file type" a custom field in your list ?] Feb 10 '20 at 7:22

Try to use the following rest api to filter files:

/_api/web/lists/getByTitle('xxx')/items?$filter=File_x0020_Type eq 'xlsx'

Refer to: https://social.technet.microsoft.com/Forums/office/en-US/1913aa3b-a23a-4e9a-aa33-e0b2742e9563/filtering-by-file-type-is-not-working-in-share-point-rest-api-onpremises?forum=sharepointgeneral

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.