Grouphubs: How to remove Role using api
- 3 years ago
Hello radhika_kundana,
Kindly use below v2 call to remove/add a role for a user from/to group hub:PUT https://{community-domain}/api/2.0/users/<user.id>
Headers:Content-Type
- application/json
Body:
{ "data":{ "type":"user", "roles_to_remove":["g:<grouphub-id>:<Member/Owner>" ] } }In case you want to add a user just change the body parameter from roles_to_remove to roles_to_add.
Here is the doc you can take a look: https://developer.khoros.com/khoroscommunitydevdocs/docs/remove-a-role-from-a-user
Hope that helps.
Regards,
Abhishek Gupta - 3 years ago
Hello radhika_kundana
For your first question, Why below call is not working:https://community.lithium.com/restapi/vc/groups/id/<grouphub-id>/roles/name/<Member/Owner>/users/remove?role.user=/users/login/<username>
Because you were using groups instead of grouphubs, even if you use grouphubs it will not work. Because grouphub is a new feature and not being added to v1 calls mostly.
Now the only option we have is v2 call and this call can be made from an Administrator and that's very sensible because other users should not have access to remove anyone's roles from grouphub.
So i would suggest you add this call to a button and Display the button to admins only .
Hope that helps.
Regards,
Abhishek Gupta