API to get Org units a form is assigned to

Hi, everyone.

I am looking for an API to fetch all org units a form is assigned to.

Thanks

exemple on play

https://play.im.dhis2.org/stable-2-41-0-1/api/dataSets/lyLU2wR22tC.json?fields=id,name,organisationUnits[id,name]

you might be interested to read :

2 Likes

Hi @Stephan_Mestach.

The API works, but does it have to be one dataset at a time or is it possible to get all datasets and the org units they are are attached to in the same API?

Thankks

Fetching them all might be ok, depending on your instance size. If the pyramid is too big or you have way too much datasets, or both… this can become a performance/stability problem for your server.

you can fetch everything at once via

https://play.im.dhis2.org/stable-2-41-0-1/api/dataSets.json?fields=id,name,organisationUnits[id,name]&paging=false

you can fetch several by dataset ids

https://play.im.dhis2.org/stable-2-41-0-1/api/dataSets.json?filter=id:in:[lyLU2wR22tC,eZDhcZi6FLP]&fields=id,name,organisationUnits[id,name]
1 Like