0

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.

1
  • Is "file type" a custom field in your list ?] Commented Feb 10, 2020 at 7:22

1 Answer 1

0

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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.