# My curl command does not work when i add a filter

**URL:** <https://devforum.okta.com/t/my-curl-command-does-not-work-when-i-add-a-filter/8651>\
**Category:** API\
**Tags:** api\
**Created:** [March 30, 2020, 8:49am UTC](https://devforum.okta.com/t/my-curl-command-does-not-work-when-i-add-a-filter/8651 "2020-03-30T08:49:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pjotrb](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pjotrb](https://devforum.okta.com/u/Pjotrb)\
**Post date:** [March 30, 2020, 8:49am UTC](https://devforum.okta.com/t/my-curl-command-does-not-work-when-i-add-a-filter/8651/1 "2020-03-30T08:49:19Z")

</div>

Hi, a stupid question, but i am just completely stuck here.

I have a cURL call that works fine:

curl -v -X GET   
-H “Accept: application/json”   
-H “Content-Type: application/json”   
-H “Authorization: SSWS ${api\_token}”   
“${url}/api/v1/users”

But now, when i add a filter to the last line:

“${url}/api/v1/users?filter=status+eq+“ACTIVE””

I get : HTTP status 400 - bad request.

(it does not show in the example but the double quotes around the ACTVE are preceded by a backslash)

I retyped, copied from examples, etc etc. but i cannot get it right  
What am i missing here ?

Thanks, Peter

---

<div class="post-metadata">

**Author:** ![chu123](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/chu123/32/1816_2.png) [@chu123](https://devforum.okta.com/u/chu123)\
**Post date:** [March 30, 2020, 7:18pm UTC](https://devforum.okta.com/t/my-curl-command-does-not-work-when-i-add-a-filter/8651/2 "2020-03-30T19:18:06Z")

</div>

You need to URL encode the quotation marks and spaces when using the filter paramter.

I.e.:` ?filter=status%20eq%20%22ACTIVE%22&limit=1`

For example, try this:

```auto
curl --location --request GET 'https://REPLACE_WITH_YOUR_TENANT/api/v1/users?filter=status%20eq%20%22ACTIVE%22&limit=1' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: SSWS REPLACE_WITH_YOUR_API_KEY'

```

Of course, I cheated. 🙂 I just use Postman and click on the “code” button. This can generate a properly formed CURL command.

---

<div class="post-metadata">

**Author:** ![dragos](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/dragos/32/1313_2.png) [@dragos](https://devforum.okta.com/u/dragos)\
**Post date:** [March 31, 2020, 2:18am UTC](https://devforum.okta.com/t/my-curl-command-does-not-work-when-i-add-a-filter/8651/3 "2020-03-31T02:18:43Z")

</div>

Hi @Pjotrb

As @chu123 mentioned, the `filter` value needs to be URL encoded. The same applies for `search` query parameter.

---

<div class="post-metadata">

**Author:** ![Pjotrb](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pjotrb](https://devforum.okta.com/u/Pjotrb)\
**Post date:** [March 31, 2020, 6:17am UTC](https://devforum.okta.com/t/my-curl-command-does-not-work-when-i-add-a-filter/8651/4 "2020-03-31T06:17:20Z")

</div>

> [@chu123](#):
>
> ode the quotat

YES! that was it, thanks guys !

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 23, 2024, 11:01pm UTC](https://devforum.okta.com/t/my-curl-command-does-not-work-when-i-add-a-filter/8651/5 "2024-01-23T23:01:21Z")

</div>

Closed on January 23, 2024, 11:01pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
