Proper filter format for listUsers method from client class Skip to main content
https://support.okta.com/help/answers?id=9062a000000querqak&refurl=http%3a%2f%2fsupport.okta.com%2fhelp%2fanswers
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
1
2
3
4
5
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Bhima Mohammed Kani Sahul HameedBhima Mohammed Kani Sahul Hameed 

Proper filter format for listUsers method from client class

We are using clinet.listUsers method to search for user in Okta. But not sure about the proper format of filter to use. From api document we found this method, 

listUsers
@Generated(value="com.okta.swagger.codegen.OktaJavaClientApiCodegen", date="2017-09-05T20:10:20.883-04:00", comments="GET - /api/v1/users") UserList listUsers(String q, String filter, String format, String search, String expand)
List Users Lists users in your organization with pagination in most cases. A subset of users can be returned that match a supported filter expression or search criteria.
Parameters:
q - Finds a user that matches firstName, lastName, and email properties (optional)
filter - Filters users with a supported expression for a subset of properties (optional)
format - (optional)
search - Searches for users with a supported filtering expression for most properties (optional)
expand - (optional)
Returns:
UserList

We are getting below exception when we tried filter parameter with "employeeNumber=".

Exception in thread "main" com.okta.sdk.resource.ResourceException: HTTP -1, Okt
a E0000031 (Invalid search criteria.), ErrorId oae44k-s9JcSXmzPiaV24eokg
        at com.okta.sdk.impl.ds.DefaultDataStore.execute(DefaultDataStore.java:5
91)
        at com.okta.sdk.impl.ds.DefaultDataStore.access$000(DefaultDataStore.jav
a:75)
        at com.okta.sdk.impl.ds.DefaultDataStore$1.filter(DefaultDataStore.java:
296)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:47)
        at com.okta.sdk.impl.ds.ProviderAccountResultFilter.filter(ProviderAccou
ntResultFilter.java:29)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:52)
        at com.okta.sdk.impl.ds.cache.WriteCacheFilter.filter(WriteCacheFilter.j
ava:70)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:52)
        at com.okta.sdk.impl.ds.cache.ReadCacheFilter.filter(ReadCacheFilter.jav
a:53)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:52)
        at com.okta.sdk.impl.ds.DefaultDataStore.getResourceData(DefaultDataStor
e.java:309)
        at com.okta.sdk.impl.ds.DefaultDataStore.getResource(DefaultDataStore.ja
va:225)
        at com.okta.sdk.impl.ds.DefaultDataStore.getResource(DefaultDataStore.ja
va:213)
        at com.okta.sdk.impl.client.DefaultClient.listUsers(DefaultClient.java:3
22)
        at com.kohls.okta.user.OktaUserDelete.run(OktaUserDelete.java:38)
        at com.kohls.okta.user.OktaUserDelete.main(OktaUserDelete.java:23)

C:\Users\tkmacf2\Documents\OktaDelete>pause
Press any key to continue . . .

When we tried using search parameter, we are getting below exception

Exception in thread "main" com.okta.sdk.resource.ResourceException: HTTP -1, Okt
a E0000015 (You do not have permission to access the feature you are requesting)
, ErrorId oaesqrl4lBTRsyVf6zTHJAGkA
        at com.okta.sdk.impl.ds.DefaultDataStore.execute(DefaultDataStore.java:5
91)
        at com.okta.sdk.impl.ds.DefaultDataStore.access$000(DefaultDataStore.jav
a:75)
        at com.okta.sdk.impl.ds.DefaultDataStore$1.filter(DefaultDataStore.java:
296)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:47)
        at com.okta.sdk.impl.ds.ProviderAccountResultFilter.filter(ProviderAccou
ntResultFilter.java:29)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:52)
        at com.okta.sdk.impl.ds.cache.WriteCacheFilter.filter(WriteCacheFilter.j
ava:70)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:52)
        at com.okta.sdk.impl.ds.cache.ReadCacheFilter.filter(ReadCacheFilter.jav
a:53)
        at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.jav
a:52)
        at com.okta.sdk.impl.ds.DefaultDataStore.getResourceData(DefaultDataStor
e.java:309)
        at com.okta.sdk.impl.ds.DefaultDataStore.getResource(DefaultDataStore.ja
va:225)
        at com.okta.sdk.impl.ds.DefaultDataStore.getResource(DefaultDataStore.ja
va:213)
        at com.okta.sdk.impl.client.DefaultClient.listUsers(DefaultClient.java:3
22)
        at com.kohls.okta.user.OktaUserDelete.run(OktaUserDelete.java:38)
        at com.kohls.okta.user.OktaUserDelete.main(OktaUserDelete.java:23)

C:\Users\tkmacf2\Documents\OktaDelete>pause
Press any key to continue . . .

 
Mihai BalasaMihai Balasa (Okta, Inc.)

Hello,

What you experience appears to be the expected behavior, as the search criteria is limited.
Please refer to our documentation for more details:

https://developer.okta.com/docs/api/resources/users.html#list-users-with-a-filter

Kind regards,
Mihai Balasa
Okta Support

Bhima Mohammed Kani Sahul HameedBhima Mohammed Kani Sahul Hameed
We are the super admins in our preview environment. But still we are getting "Exception in thread "main" com.okta.sdk.resource.ResourceException: HTTP -1, Okt
a E0000015 (You do not have permission to access the feature you are requesting)
, ErrorId oaesqrl4lBTRsyVf6zTHJAGkA" error.

Provided link clearly says we can use search attribute to list user with custom defined properties.

Method using is List Users with Search