Fetching Groups assigned to a Application using Java SDK

Hi,
I’m trying to get a list of Groups assigned to a Application from Java SDK and using below code.
String search=“source.id%20eq%20%220oa3mgdp2XRMOLJYv1d6%22”;
GroupList grpList = client.listGroups(null, search, null);

But Im gettting below error:
"HTTP 400, Okta E0000031 (Invalid search criteria.), ErrorId oaevpxB3-xuRJyQ1c8-rgIpKQException in thread “main”
com.okta.sdk.resource.ResourceException: HTTP 400, Okta E0000031 (Invalid search criteria.), ErrorId oaevpxB3-xuRJyQ1c8-rgIpKQ

In source.id I’m passing the Application id. I have seen few examples using REST API but not from java api.
Could you please provide few examples how the parameters “q”, “search”, “expand” needs to be formed for this method.

Client. listGroups(java.lang.String q, java.lang.String search, java.lang.String expand)

Thanks & Regards
Suresh

@sureshponnada Hi, Please refer the API doc [here] (Groups | Okta Developer). It contains examples of list group with filter. I suggest you can test in postman first before running it through codes.

Hi Lijia, Thanks for your response. I’ve referred those examples meant for REST API. I’m working on migration project so developing my scripts in Okta java sdk.
e.g. in REST API below search will work:
https://${yourOktaDomain}/api/v1/groups?filter=type+eq+“OKTA_GROUP”&limit=200”

same I need to pass to Client.listGroups(String q, String filter, String expand)
so I’ve formed filter string in few combinations provided below but nothing is working.
String filter =“type%20eq%20%22OKTA_GROUP%22”;
String filter =“type+eq+“OKTA_GROUP””;
String filter =“filter=type+eq+“OKTA_GROUP””;

Here I’m passing Type = Okta_group withURL encoded as mentioned in the documentation.
If i pass all nulls in Client.listGroups(null, null, null) I’m getting the results. so Issue is only in the way I’m passing “filter”.

This is now resolved after i passed the below filter. It looks like i don’t need to do URLEncoded for the parameter.

 String search ="type eq \"OKTA_GROUP\"";

Thanks & Regards
Suresh

1 Like

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