Forum Discussion

santosh_csc's avatar
7 years ago

How to get all the roles created for a groups?

I have created Role-1, Role-2, Role-3 for a group with default role as Role-1.

When a user is Inviting, They can invite to any of these 3 roles.

 

When a user comes to community, I want to get the role in which he got invited. Is there any API provides such info?

If not, then is there any way to get users with roles in that specific groups?

 

When I ran 

https://community.lithium.com/restapi/vc/groups/id/ggg/?restapi.response_format=json

It gives the ID of default role. Not all the roles present for that group. How to get this detail as well? 

 

  • santosh_csc - We faced a similar issue 3 years ago where we couldn’t find any call which would fetch the user of the current group based on the roles. We wanted to highlight the user with GroupAdmin role inside a group, but the role wasn't returned in the users/id/roles api, nor is there any direct call for this. After a lot of to and fro with the support, there were some additional calls which they suggested, here is one of the final answers which we got from them. Please note that this is from 2014.


    I heard back from our development team, and it looks like they had cited the incorrect API calls to utilize for this. The calls they added were actually specific for group roles:

    /restapi/vc/groups/id/<group id>/group_roles
    /restapi/vc/groups/id/<group id>/group_roles/count
    /restapi/vc/groups/id/<group id>/group_roles/create?role.name=<role name>

    So in your example on stage, I would run this call to get the list of roles:

    /restapi/vc/groups/id/opt_group/group_roles

    Building on that, since we can get the group IDs easily using that API call you can then make calls to the specific role ID. For example, I used the Washington role on your "opt_group" here:

    /restapi/vc/roles/id/351/

    I hope this helps.

  • santosh_csc - We faced a similar issue 3 years ago where we couldn’t find any call which would fetch the user of the current group based on the roles. We wanted to highlight the user with GroupAdmin role inside a group, but the role wasn't returned in the users/id/roles api, nor is there any direct call for this. After a lot of to and fro with the support, there were some additional calls which they suggested, here is one of the final answers which we got from them. Please note that this is from 2014.


    I heard back from our development team, and it looks like they had cited the incorrect API calls to utilize for this. The calls they added were actually specific for group roles:

    /restapi/vc/groups/id/<group id>/group_roles
    /restapi/vc/groups/id/<group id>/group_roles/count
    /restapi/vc/groups/id/<group id>/group_roles/create?role.name=<role name>

    So in your example on stage, I would run this call to get the list of roles:

    /restapi/vc/groups/id/opt_group/group_roles

    Building on that, since we can get the group IDs easily using that API call you can then make calls to the specific role ID. For example, I used the Washington role on your "opt_group" here:

    /restapi/vc/roles/id/351/

    I hope this helps.