How to retrieve list of all superuser and admin using API in DHIS2

Dear Developer

How to retrieve list of all superuser and admin using API in DHIS2

Regards

User extended App can also do the magic

1 Like

@Tedson add more details, which app are you talking about

@Shapr0019 If you have super user rights of your instance go to app management and install an application called User extended app. You are able to export users by User role and user group

image

1 Like

Hi there! I think you can list users belonging to a certain group by using the userGroups API. Please use the API sample below to see how to get the user ids of a group. Kindly note that you will have to know the group ID of the super user group

http://YOUR_SERVER_URL/api/userGroups/GROUP_ID.json

This is an example of a working API using the play.dhis2.org instance
DHIS 2 Demo - Sierra Leone

1 Like

Hie @Tedson
Thank you very much for providing a very straight forward answer. The App is excellent. However, I wanted to use API to download all names, last log in, user roles and user group. I am developing a code script to retrieve such information.
Regards

1 Like

Hie @MiltonIsaya

This is very useful. In this case super user is not belonging to any user group. And also how to download that information vie excel file

Regards

1 Like

You can query the data and thereafter parse it to excel via the script you are writing @Shapr0019

1 Like

@MiltonIsaya thank you very much

1 Like

Hi @Shapr0019

You can filter within multiple user groups as a collection of users, as in here:

https://play.dhis2.org/2.39.0.1/api/users.json?filter=userGroups.id:in:[wl5cDMuUhmF,lFHP5lLkzVr]&fields=name,userCredentials[lastLogin],userRoles[id,name],userGroups[id,name]

This should get you the fields you require. Replace
userGroups.id:in:[wl5cDMuUhmF,lFHP5lLkzVr] with the UIDs of your super user and admin userGroups.

The same applies for userRoles

2 Likes