# How to get users in few specific groups?

**URL:** <https://devforum.okta.com/t/how-to-get-users-in-few-specific-groups/18146>\
**Category:** API\
**Tags:** api, java\
**Created:** [November 19, 2021, 3:02am UTC](https://devforum.okta.com/t/how-to-get-users-in-few-specific-groups/18146 "2021-11-19T03:02:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![angeline.alex](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@angeline.alex](https://devforum.okta.com/u/angeline.alex)\
**Post date:** [November 19, 2021, 3:02am UTC](https://devforum.okta.com/t/how-to-get-users-in-few-specific-groups/18146/1 "2021-11-19T03:02:27Z")

</div>

I need to get the list of users in a specific group or I can filter the group in my code. I need the list of users in my application.

I tried the following nothing worked.  
[https://xxx.oktapreview.com/api/v1/users/](https://xxx.oktapreview.com/api/v1/users/)  
[https://xxx.oktapreview.com/api/v1/users/](https://xxx.oktapreview.com/api/v1/users/)/groups  
[https://xxx.oktapreview.com/api/v1/groups?filter=type](https://xxx.oktapreview.com/api/v1/groups?filter=type) eq admin\_name  
[https://xxx.oktapreview.com/api/v1/groups?q=admin\_name](https://xxx.oktapreview.com/api/v1/groups?q=admin_name)  
[https://xxx.oktapreview.com/oauth2/default/v1/groups](https://xxx.oktapreview.com/oauth2/default/v1/groups)  
[https://xxx.oktapreview.com/oauth2/default/api/v1/groups](https://xxx.oktapreview.com/oauth2/default/api/v1/groups)

Can someone help me. I am getting 4xx error for all the above when i try in java.

I have posted 2 different post for with the details.

> [@405 error for while hitting /groups endpoint for the user](https://devforum.okta.com/t/405-error-for-while-hitting-groups-endpoint-for-the-user/18071/3):
>
> I am not really sure about that. I did restart my system and also eclipse… it didnt not help.

> [@Getting 400 error while hitting groups endpoint](https://devforum.okta.com/t/getting-400-error-while-hitting-groups-endpoint/18068/3):
>
> Missed to add a line. Updated.

---

<div class="post-metadata">

**Author:** ![gpushpakumar](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@gpushpakumar](https://devforum.okta.com/u/gpushpakumar)\
**Post date:** [November 19, 2021, 4:52am UTC](https://devforum.okta.com/t/how-to-get-users-in-few-specific-groups/18146/2 "2021-11-19T04:52:34Z")

</div>

try this https://${yourOktaDomain}/api/v1/groups/${groupid}/users

[https://developer.okta.com/docs/reference/api/groups/#group-member-operations](https://developer.okta.com/docs/reference/api/groups/#group-member-operations)

If you looking for users in a Application then check out this

[https://developer.okta.com/docs/reference/api/apps/#list-users-assigned-to-application](https://developer.okta.com/docs/reference/api/apps/#list-users-assigned-to-application)

---

<div class="post-metadata">

**Author:** ![jmussman](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/jmussman/32/2175_2.png) [@jmussman](https://devforum.okta.com/u/jmussman)\
**Post date:** [November 19, 2021, 4:55am UTC](https://devforum.okta.com/t/how-to-get-users-in-few-specific-groups/18146/3 "2021-11-19T04:55:20Z")

</div>

Hi! Hmm. A 405 “Method not allowed” would usually indicate you are doing something other than GET to try to retrieve this from the API. For example, POST, PUT, etc. wouldn’t be accepted.

Now, once you are beyond that you can pull just the specific group by name using the “q” parameter, the fourth one in your list from above. That looks for the group name using a “starts with” operation.

Now, for the final part of your question, to get the users from a particular group look in the “\_links” section of the JSON response and grab the “users” value as the link to use. If you peek at it you will see it has the GUID for the group in the URL, so if you knew that before you could skip my middle step 🙂

---

<div class="post-metadata">

**Author:** ![angeline.alex](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@angeline.alex](https://devforum.okta.com/u/angeline.alex)\
**Post date:** [November 20, 2021, 12:47am UTC](https://devforum.okta.com/t/how-to-get-users-in-few-specific-groups/18146/4 "2021-11-20T00:47:42Z")

</div>

Thank you both for your responses.  
API call didn’t work for me unfortunately got 405/400 error. Using okta sdk solved the issue. There is a built in listGroups method helped.

---

<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:** [November 21, 2021, 12:48am UTC](https://devforum.okta.com/t/how-to-get-users-in-few-specific-groups/18146/5 "2021-11-21T00:48:35Z")

</div>

Closed on November 21, 2021, 12:48am UTC

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