14

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?

25

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
    remove the parenthesis. $filter=ZIP eq 12345 or ZIP eq 22222 – Atish Dipongkor - MVP Nov 25 '15 at 15:32
  • 1
    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')) – Anand May 22 '18 at 14:41

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.