# How to get role list

**URL:** <https://forum.keycloak.org/t/how-to-get-role-list/1989>\
**Category:** Miscellanaeous\
**Created:** [April 6, 2020, 11:06am UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989 "2020-04-06T11:06:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![emerson01](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@emerson01](https://forum.keycloak.org/u/emerson01)\
**Post date:** [April 6, 2020, 11:06am UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989/1 "2020-04-06T11:06:40Z")

</div>

I am seeing a keycloak documentation on listing as roles and the example is:

Get all roles for the domain or client  
GET / {region} / customers / {id} / roles

Does anyone have a practical example for listing as roles using “curl or postman”

Original Doc: [https://www.keycloak.org/docs-api/5.0/rest-api/index.html#\_roles\_resource](https://www.keycloak.org/docs-api/5.0/rest-api/index.html#_roles_resource)

Appreciate

---

<div class="post-metadata">

**Author:** ![zonaut](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/zonaut/32/666_2.png) [@zonaut](https://forum.keycloak.org/u/zonaut)\
**Post date:** [April 6, 2020, 11:19am UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989/2 "2020-04-06T11:19:26Z")

</div>

Where do you get that region and customers string in the path, the docs says `GET /{realm}/clients/{id}/roles`

---

<div class="post-metadata">

**Author:** ![emerson01](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@emerson01](https://forum.keycloak.org/u/emerson01)\
**Post date:** [April 6, 2020, 12:57pm UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989/3 "2020-04-06T12:57:17Z")

</div>

Yes I would like an example of how to do this using a tool with Curl or. Postman

---

<div class="post-metadata">

**Author:** ![zonaut](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/zonaut/32/666_2.png) [@zonaut](https://forum.keycloak.org/u/zonaut)\
**Post date:** [April 6, 2020, 1:10pm UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989/4 "2020-04-06T13:10:36Z")

</div>

Here is an example on how you could do this with curl, put it in a bash script.

`DIRECT_GRANT_RESPONSE=$(curl -i --request POST "http://localhost:8080/auth/realms/master/protocol/openid-connect/token" --header "Accept: application/json" --header "Content-Type: application/x-www-form-urlencoded" --data "grant_type=password&username=admin&password=password&client_id=admin-cli")`

`ACCESS_TOKEN=$(echo $DIRECT_GRANT_RESPONSE | grep "access_token" | sed 's/.*\"access_token\":\"\([^\"]*\)\".*/\1/g');`

`curl --request GET "http://localhost:8080/auth/admin/realms/realm-name/clients/client-id/roles" --header "Accept: application/json" --header "Authorization: Bearer $ACCESS_TOKEN" | python -m json.tool;`

---

<div class="post-metadata">

**Author:** ![emerson01](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@emerson01](https://forum.keycloak.org/u/emerson01)\
**Post date:** [April 6, 2020, 7:01pm UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989/5 "2020-04-06T19:01:08Z")

</div>

Thank you . But when I try I get the message.  
error": “HTTP 401 Unauthorized”

---

<div class="post-metadata">

**Author:** ![emerson01](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@emerson01](https://forum.keycloak.org/u/emerson01)\
**Post date:** [April 6, 2020, 7:36pm UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989/6 "2020-04-06T19:36:50Z")

</div>

Sorry now the problem is :

“error”: “RESTEASY003210: Could not find resource for full path: [http://localhost:8080/auth/admin/realms/demo/clients/1b62710a-6b2a-4e43-b8da-d8b6177952b5/role](http://localhost:8080/auth/admin/realms/demo/clients/1b62710a-6b2a-4e43-b8da-d8b6177952b5/role)”

---

<div class="post-metadata">

**Author:** ![zonaut](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/zonaut/32/666_2.png) [@zonaut](https://forum.keycloak.org/u/zonaut)\
**Post date:** [April 6, 2020, 8:14pm UTC](https://forum.keycloak.org/t/how-to-get-role-list/1989/7 "2020-04-06T20:14:27Z")

</div>

/{realm}/clients/{id}/roles your url is incomplete, role -\> roles
