# Java SDK - fitlering users

**URL:** <https://devforum.okta.com/t/java-sdk-fitlering-users/1880>\
**Category:** API\
**Tags:** java\
**Created:** [May 31, 2018, 4:25pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880 "2018-05-31T16:25:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisc](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@chrisc](https://devforum.okta.com/u/chrisc)\
**Post date:** [May 31, 2018, 4:25pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/1 "2018-05-31T16:25:38Z")

</div>

Hi,

I am trying to use the Java SDK to list users using a filter. I can get a Curl request to work properly but have not hit on the correct encoding of the method parameters to get the filter to work. I’d like to filter by profile.emailVerificationStatus.

```auto
/api/v1/users?filter%3Dprofile.emailVerificationStatus%20eq%20%22UNVERIFIED%22&limit=200

```

This works properly with Curl, but when used in the listUsers() method as the second parameter, the response is always “Invalid search criteria.”

```auto
UserList users = client.listUsers(null, "profile.emailVerificationStatus eq \"UNVERIFIED\"", null, null, null);

```

---

<div class="post-metadata">

**Author:** ![vijet](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/vijet/32/245_2.png) [@vijet](https://devforum.okta.com/u/vijet)\
**Post date:** [May 31, 2018, 4:38pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/2 "2018-05-31T16:38:45Z")

</div>

I haven’t tested the code but give this a try -  
`UserList users = client.listUsers(null, 'profile.emailVerificationStatus eq \"UNVERIFIED\"', null, null, null)`

Also, you can take a look at our integration tests for API usage - [https://github.com/okta/okta-sdk-java/blob/master/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UsersIT.groovy](https://github.com/okta/okta-sdk-java/blob/master/integration-tests/src/test/groovy/com/okta/sdk/tests/it/UsersIT.groovy)

@bdemers - This should work right?

---

<div class="post-metadata">

**Author:** ![bdemers](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/bdemers/32/23_2.png) [@bdemers](https://devforum.okta.com/u/bdemers)\
**Post date:** [May 31, 2018, 4:45pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/3 "2018-05-31T16:45:40Z")

</div>

@chrisc can you paste the code within a code block (to make sure the quotes are correct):  
`````  
`code here`  
`````

@vijet should be right, but adjusting for Java instead of groovy:  
`"profile.emailVerificationStatus eq \"UNVERIFIED\""`

---

<div class="post-metadata">

**Author:** ![chrisc](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@chrisc](https://devforum.okta.com/u/chrisc)\
**Post date:** [June 6, 2018, 5:17pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/4 "2018-06-06T17:17:26Z")

</div>

Here is the exact line that fails.

```auto
UserList users = client.listUsers(null, "profile.emailVerificationStatus eq \"UNVERIFIED\"", null, null, null);

```

From the logs I can see this is then translated to the following GET:  
“GET /api/v1/users?filter=profile.emailVerificationStatus+eq+%22UNVERIFIED%22 HTTP/1.1[\r][\n]”

With error response:  
{“errorCode”:“E0000031”,“errorSummary”:“Invalid search criteria.”,“errorLink”:“E0000031”,“errorId”:“oaeC6n-sySnQCmL-0eDG4qumw”,“errorCauses”:[]}[\r][\n]

---

<div class="post-metadata">

**Author:** ![bdemers](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/bdemers/32/23_2.png) [@bdemers](https://devforum.okta.com/u/bdemers)\
**Post date:** [June 6, 2018, 6:03pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/5 "2018-06-06T18:03:48Z")

</div>

Hey @chrisc

The issue is with the filter itself. I didn’t notice it the first time, but your original curl href was:

```auto
/api/v1/users?filter%3Dprofile...

```

It looks like your `=` char is escaped. Resulting in the query parameter key being that whole string.

Take a look at the doc for the [user filter](https://developer.okta.com/docs/api/resources/users#list-users-with-a-filter):

> Supports only a limited number of properties: `status`, `lastUpdated`, `id`, `profile.login`, `profile.email`, `profile.firstName`, and `profile.lastName`.

This will be supported via the `search` param in the future:

> **[Users | Okta Developer](https://developer.okta.com/docs/reference/api/users/)**
>
> Secure, scalable, and highly available authentication and user management for any app.

---

<div class="post-metadata">

**Author:** ![chrisc](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@chrisc](https://devforum.okta.com/u/chrisc)\
**Post date:** [June 6, 2018, 6:32pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/6 "2018-06-06T18:32:15Z")

</div>

It is strange then since this filter query can be run against the API using Curl:

curl -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -H ‘Authorization: SSWS xxx’ ‘[https://xxxx.oktapreview.com/api/v1/users?filter%3Dprofile.emailVerificationStatus%20eq%20"UNVERIFIED"&limit=200](https://xxxx.oktapreview.com/api/v1/users?filter%3Dprofile.emailVerificationStatus%20eq%20%22UNVERIFIED%22&limit=200)’

---

<div class="post-metadata">

**Author:** ![bdemers](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/bdemers/32/23_2.png) [@bdemers](https://devforum.okta.com/u/bdemers)\
**Post date:** [June 6, 2018, 7:56pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/7 "2018-06-06T19:56:14Z")

</div>

@chrisc  
It is similar to running `/api/v1/users?invalid` you need to replace the `%3D` with and `=` and you should see the same error. (you have the equals char escaped)

---

<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 12, 2024, 10:24pm UTC](https://devforum.okta.com/t/java-sdk-fitlering-users/1880/8 "2024-01-12T22:24:44Z")

</div>

Closed on January 12, 2024, 10:24pm UTC

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