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!

1
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
2
  • 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 8 '20 at 8:05
  • 1
    You need to write CAML query for filters check 2 reference link. it has the example given for the same – Ganesh Sanap May 8 '20 at 8:14

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.