22

Assuming there is a list of Students each with a zip-code, how can I get records for multiple (but not all) zip-codes.

When using $filter how do specify multiple values?

Here's what I have so far:

site.com/_api/web/Lists/getByTitle('Students')/items?$filter=ZipCode eq 12345

When I try:

site.com/_api/web/Lists/getByTitle('Students')/items?$filter=ZipCode eq '12345'&$filter=ZipCode eq '22222'

Or

site.com/_api/web/Lists/getByTitle('Students')/items?$filter=ZipCode eq '12345,22222'

These don't work, what is the right way of doing this?

1
  • Please help us know the filter condition 'like'. Requires to extract the records related to city name starts with 'NEW%' Commented Jul 7, 2020 at 22:06

1 Answer 1

37

As far as I know, you can not use &. You have to use and or or inside the filter.

So try using something like that:

/_api/web/lists/getbytitle('Students')/items?$select=Title,ZIP&$filter=((ZIP eq 12345) or (ZIP eq 22222))

I always use brackets because of the readability, but you can also use it without brackets.

items?$select=Title,ZIP&$filter=ZIP eq 12345 or ZIP eq 22222
2
  • 2
    remove the parenthesis. $filter=ZIP eq 12345 or ZIP eq 22222 Commented Nov 25, 2015 at 15:32
  • 6
    just a note. If the right Operand is a string then do include single quotes like this: /_api/web/lists/getbytitle('Students')/items?$select=Title,ZIP&$filter=((ZIP eq 12345) or (CITY eq 'New York')) Commented May 22, 2018 at 14:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.