Get current role permissions from API

While using strapi v4, and acessing the API endpoint

http://localhost:1337/api/users-permissions/permissions

I get the permissions available. Example:


"api::lead": {

            "controllers": {

                "lead": {

                    "find": {

                        "enabled": false,

                        "policy": ""

                    },

                    "findOne": {

                        "enabled": false,

                        "policy": ""

                    },

                    "create": {

                        "enabled": false,

                        "policy": ""

                    },

                    "update": {

                        "enabled": false,

                        "policy": ""

                    },

                    "delete": {

                        "enabled": false,

                        "policy": ""

                    }

                }

            }

        },

But, I would like to get the permission for the current role (administrator, public, etc.)

All the fields returned in the response of the permissions API are false, which does not reflect the reality of my current user role.

I was able to find a solution. By acessing the role I want directly, using:

http://localhost:1337/api/users-permissions/roles/1

it returns the current role with the list of permissions of that role.

it’s then possible to change the permissions and, using PUT method, update the permissions of that role via API directly.

1 Like