# Using expression in REST API

**URL:** <https://forum.mautic.org/t/using-expression-in-rest-api/20663>\
**Category:** Product Support\
**Tags:** mautic-3\
**Created:** [August 31, 2021, 2:27pm UTC](https://forum.mautic.org/t/using-expression-in-rest-api/20663 "2021-08-31T14:27:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rta\_dieulinh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rta_dieulinh/32/1107_2.png) [@rta\_dieulinh](https://forum.mautic.org/u/rta_dieulinh)\
**Post date:** [August 31, 2021, 2:27pm UTC](https://forum.mautic.org/t/using-expression-in-rest-api/20663/1 "2021-08-31T14:27:30Z")

</div>

Hi all,

I have questions about using expression to filter contacts when I using REST API

## **My software**

My Mautic version is: 3.3.1  
My PHP version is: 7.3.27  
My Database type and version is:

## **My problem**

I have contacts table (export excel)

| id | email | industry | city |
| --- | --- | --- | --- |
| 1 | [xxx@gmail.com](mailto:xxx@gmail.com) | `X\_1 | X\_2 |
| 2 | [xxy@gmail.com](mailto:xxy@gmail.com) | `X_2` | Ho Chi Minh |
| 3 | [xxz@gmail.com](mailto:xxz@gmail.com) | `X\_1 | X\_4` |
| 4 | [xxt@gmail.com](mailto:xxt@gmail.com) | `X_1` | Ha Noi |

**Included:** `industry`: multiple choices, I see mautic saves value collapsing by `|`

### I want to filter contacts having the condition:

1. The contacts have `industry` have value `(X_1 or X_2 or X_3)` and `city` contains pattern `Ha noi`

2. …

### I wrote:

Ex1:

> [MauticURL]/api/contacts?where[0][col]=industry&where[0][expr]=in&where[0][val]=X\_1,X\_2,X\_3&where[1][col]=city&where[1][expr]=like&where[1][val]=‘%Ha Noi%’

Result:

| id | email | industry | city |
| --- | --- | --- | --- |
| 4 | [xxt@gmail.com](mailto:xxt@gmail.com) | `X_1` | Ha Noi |

Ex2:

> [MauticURL]/api/contacts?orWhere(where[0][col]=industry&where[0][expr]=in&where[0][val]=X\_1)&orWhere(where[0][col]=industry&where[0][expr]=in&where[0][val]=X\_2)orWhere(where[0][col]=industry&where[0][expr]=in&where[0][val]=X\_3)

I see the `orWhere` in [doc](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/query-builder.html#high-level-api-methods) but when I use, response returns `Looks like I encountered an error (error #500)`.

### **Expected result:**

| id | email | industry | city |
| --- | --- | --- | --- |
| 1 | [xxx@gmail.com](mailto:xxx@gmail.com) | `X\_1 | X\_2 |
| 4 | [xxt@gmail.com](mailto:xxt@gmail.com) | `X_1` | Ha Noi |

How can I do that? Thank you so much.
