API enrollments visualization

Hi all,

I want to view some attributes (name, gender) of all enrollments in a certain program assigned to an org unit (including its descendants).
Could you help me change this API to get my desired result?

Thanks

Hi @fernandoshake,
The API request you posted helped, thanks! You were doing it correctly except the endpoint you used in enrollments, but to be able to view the attributes, you’d need to use the trackedEntityInstances endpoint:
/api/trackedEntityInstances?fields=enrollments,attributes&ou=DiszpKrYNg8&ouMode=DESCENDANTS&order=created:desc&program=IpHINAT79UW~~&paging=false~~

Hi @Gassim,

Thank you. The API request does work very well, but when I try to display the result as csv, it show an empty file. I just added csv extension after TrackedEntityInstances. Is it correct to put csv before question mark?

Thanks

Hi @fernandoshake

Please what’s not working very well. Do you get the desired result when using .json?

You are right! Would you like to create a jira bug issue on jira.dhis2.org?

Thank you!

Hi @Gassim ,

Using json, I get the result. Why not in csv?

Thanks

Yes sorry this is a bug issue. I have created a Jira bug issue here: Log in - DHIS 2 JIRA

You can ‘watch’ this issue for updates/comments, and add your vote to prioritize. :+1:

Perhaps a small aside, but do be really really careful about setting paging=false like this. If this was a vaccination campaign with potentially 10s of millions of TEIs, you can easily crash the server like this. Rule of thumb : always use paging.

1 Like

:100:
Yes! Thanks!:+1:

/api/trackedEntityInstances?fields=enrollments,attributes&ou=DiszpKrYNg8&ouMode=DESCENDANTS&order=created:desc&program=IpHINAT79UW

Without the paging=false, and maybe replace it with pageSize=[number of items to be displayed]