Is it possible to select only record that has children

I am new to DHIS2. I have an API call to DHIS2 and I want to select only those record that has children. I use the &children=true but the result still list those with “hasChildren”:false,

Could you advice?

Sam

Hi

&children=true is supposed to be correct, would you share the complete API request (without main domain URL)?

Thank you!

Dear AL-Gassim Sharaf Addin

API request below is to list entities that do not have children. I have added the ‘&children=false’ at the end of the API.
The result I got was:
{“children”:[{“id”:“WSN6D1Nmr5L”,“hasChildren”:true,“name”:…

Please find below full API below
api/29/organisationUnits/UzOk2ito9aI.json?node=UzOk2ito9aI&fields=children%5Bid%2CdisplayName~rename(name)%2Cchildren%3A%3AisNotEmpty~rename(hasChildren)%26paging%3Dfalse&children=false

Thank you.
Sam

Please see the following API request in play instance dhis2 version 40:
https://play.dhis2.org/40.0.1/api/organisationUnits?fields=code,name,children&filter=children:gt:1

As you can see, I used the metadata object filter filter=children:gt:1 to filter out all those that have no children; whereas the field I only selected code, name, and children. It is possible to view more fields and to filter even further depending on your use case.

Sorry for not answering your question right away, but I hope this helps. Please refer to the API documentation for further information: Introduction - DHIS2 Documentation And let us know if you have more questions or need additional resources.

You’re always welcome to post to the community :heavy_heart_exclamation:

Thanks! :slight_smile: