I am using the Wazuh4.3 API to modify the user role using a post request, but return the Missing query parameter 'role to me_ Ids, could you please tell me how to solve it
I have checked the official latest documentation, but I have not found a solution. There is very little information on the latest version on the search engine.
You should be able to switch the role a user belongs to in this way:
# Unassign previous role (optional)
curl -k -X DELETE "https://localhost:55000/security/users/<USER_ID>/roles?role_ids=<ROLE_ID>" -H "Authorization: Bearer $TOKEN"
# Assign new role
curl -k -X POST "https://localhost:55000/security/users/<USER_ID>/roles?role_ids=<NEW_ROLE_ID>" -H "Authorization: Bearer $TOKEN"
For example:
# Unassign previous role (optional)
curl -k -X DELETE "https://localhost:55000/security/users/100/roles?role_ids=100" -H "Authorization: Bearer $TOKEN"
# Assign new role
curl -k -X POST "https://localhost:55000/security/users/100/roles?role_ids=101" -H "Authorization: Bearer $TOKEN"
You can list the current users (id, name and roles) and roles like this:
# List users
curl -k -X GET "https://localhost:55000/security/users?pretty=True" -H "Authorization: Bearer $TOKEN"
# List roles
curl -k -X GET "https://localhost:55000/security/roles?pretty=True" -H "Authorization: Bearer $TOKEN"
Here is the full API reference for the latest version, in case you find it useful: