Creating a client-level role using the API

Hello. I am using Postman. If it works there, then I can use the code in C#.

So I have been searching for ways to create a client-level role in Keycloak. I’ve searched StackOverflow, this site, and GitHub. So far, I have not found anything that could help me.

The official documentation states that the endpoint should be like this:
POST /{realm}/clients/{id}/roles

Which should then translate to something like this:
{baseUrl}/auth/admin/realms/{realmName}/clients/{clientId}/roles (client is “admin-cli”)

Then get the auth_token using the credentials of a user with a realm-admin role and the built-in client “admin-cli”. Use that for authorization.

Finally, use something like this in the body under content-type: application/json:
[{
“name”: “test-name”
}]

This always results in an “Error: Unknown Error” or "500 Internal Server Error"

Making realm-level roles is a snap. But I need client-level roles. Is it at all possible using the API?

Solved it myself.

OK. The endpoint was correct. What got me stuck was this: [{}] (JSON array)

It should have been this: {} (JSON object).