Ankush Garg
Ankush Garg

Reputation: 35

Filtering data using rest api fetched from Document library in SharePoint

I am able to fetch the documents that are uploaded into the document library of SharePoint online. Now I want to filter the contents that are getting fetched based on a Lookup column and Choice column. But filter is not working in rest api. Can anyone help here? Below is the part of the url I am using.

/items?$select=,FieldValuesAsText/FileRef&$expand=FieldValuesAsText&$
                                              filter=FieldValuesAsText eq ‘Workbook.xlsx'",

Upvotes: 1

Views: 4457

Answers (2)

Hoorie
Hoorie

Reputation: 1

you can try this one:

/_api/web/Lists('ListGUID')/items?$select=FieldValuesAsText/FileRef&$expand=FieldValuesAsText&$filter=FileLeafRef eq 'filename.txt'

Upvotes: 0

LZ_MSFT
LZ_MSFT

Reputation: 4228

If you want to filter data by file name, we can use the rest api below.

/_api/web/lists/getbytitle('DL')/items?$select=*,FieldValuesAsText&$expand=FieldValuesAsText&$Filter=FileLeafRef eq 'Workbook.xlsx'

If you want to filter data base on lookup field and choice file, we can use this. In my test, the lookup field is "MyLookup" and choice field is "MyChoice".

/_api/web/lists/getbytitle('DL')/items?$select=*,FieldValuesAsText,MyLookup/Title&$expand=MyLookup&$Filter=MyChoice eq 'Choice1' and MyLookup/Title eq 'lookup1'

Upvotes: 1

Related Questions