Assistance: API call - Nested query

Hey @dmbantu,
I will share with you an example from the play.dhis2.org instance. First here’s the link: https://play.dhis2.org/2.37.0/api/trackedEntityInstances?fields=attributes[displayName,value]&ou=DiszpKrYNg8&program=IpHINAT79UW&pageSize=50&page=1&totalPages=false you’d have to be logged in to DHIS 2 Demo - Sierra Leone to see it.

First, there are two main requirements to get the TEI: OU & program (and you could get their IDs from the Maintenance app), and then for your request I used the fields parameter to choose what I want to be displayed which in this case is attributes. I could have chosen to just keep it as fields=attributes; however, if I don’t want to see all the details such as “lastUpdated”…etc then I could specify what I want in closed brackets such as fields=attributes[displayName,value]. You could start with fields=* to all the possible selections and then choose the info you want.

For example, in addition to displaying the attributes, I could display the status of the enrollment:
https://play.dhis2.org/2.37.0/api/trackedEntityInstances?fields=enrollments[status],attributes[displayName,value]&ou=DiszpKrYNg8&program=IpHINAT79UW&pageSize=50&page=1&totalPages=false and all I did was add enrollments[status]

I hope this clarifies a bit please let me know if you want any additional info! Thanks! (: