0

I would like to get the items whose field A is IN (X,Y,Z...).

I've seen ways to do it with ORs (Rest API - $filter multiple values) but is there a simpler way?

Something like:

/_api/web/lists/getbytitle('Students')/items?$select=Title,ZIP&$filter=(ZIP IN [111,222,333,444])

Thanks!

Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61
Gelu
  • 107
  • 2

1 Answers1

1

You can use IN operator in CAML query with SharePoint REST API's GetItems endpoint.

Example of IN operator uses:

<Where>
  <In>
    <FieldRef Name="ID" />
    <Values>
       <Value Type="Number">1</Value>
       <Value Type="Number">2</Value>
       .
       .
       .
       <Value Type="Number">530</Value>
    </Values>
  </In>
</Where>

References:

  1. In element (Query)
  2. Make CAML query with in rest api call
  3. SharePoint REST API - CAML Query
Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61
  • Thanks, is it possible to use it in the filters in the url of the REST query? If so, what's the syntax? I've googled around but no luck. – Gelu May 08 '20 at 08:05
  • 1
    You need to write CAML query for filters check 2 reference link. it has the example given for the same – Ganesh Sanap - MVP May 08 '20 at 08:14