cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to list users group with sap bo rest api?

Can4
Explorer
0 Kudos
482

Hi,

I want to get usergroups of a user. I am trying v1/users/{userId}/userGroups but it return 404. There are couple of endpoints like v1/userGroups/<usergroup_id>/users but it return users in a userGroup. I need to get user groups of a user. How can I achieve this using rest api?

Accepted Solutions (0)

Answers (1)

Answers (1)

ayman_salem
Active Contributor
0 Kudos

You can use cmsquery (http://<baseURL>/v1/cmsquery) and write the desired query in the body.

For information on using CMS query with RESTful API, see CMS Query

Example query:   

SELECT SI_ID, SI_NAME, SI_USERGROUPS FROM CI_SYSTEMOBJECTS WHERE SI_NAME='TestA' and 
SI_KIND = 'User'

ayman_salem_0-1727785693125.png

 

SELECT SI_ID, SI_NAME, SI_USERGROUPS FROM CI_SYSTEMOBJECTS WHERE SI_KIND = 'UserGroup'
ayman_salem_1-1727786795094.png

....

I hope this helps you get on the right track.





Can4
Explorer
0 Kudos
Thank you so much. I want to ask another question related this question. How can I remove a user from all user groups they belong to?
ayman_salem
Active Contributor
0 Kudos

is not possible with RESTful, you have to delete the user from each group he belongs to individually

DELETE http://<baseURL>/v1/usergroups/<usergroup_id>/users

see  Removing Users from a User Group

Can4
Explorer
0 Kudos
Ok, First, I will get the ids of all user groups belonging to the user with the cms query, then I will use this id in the endpoint you sent, send the user_id to the body and complete the process, right?
ayman_salem
Active Contributor
0 Kudos
Correct