Hello,
I’m trying to query organisation Units using the parameters maxLevel
and withinUserHiearchy
as indicated in the documentation. The challenge I’m facing is that the response comes with the correct list of organisation units but the paging on the response seems to be for the total organisation units in the instance.
Example the query:
https://play.dhis2.org/2.36.3/api/organisationUnits.json?maxLevel=2&fields=id,level&pageSize=50&withinUserHierarchy=true&totalPages=true,page=2
Only has 13 organisation units but the response is (note the pager)
{
"pager": {
"page": 1,
"pageCount": 27,
"total": 1332,
"pageSize": 50,
"nextPage": "https://play.dhis2.org/2.36.3/api/organisationUnits.json?page=2&maxLevel=2&totalPages=true%2Cpage%3D2&fields=id%2Clevel&withinUserHierarchy=true"
},
"organisationUnits": [
{
"level": 2,
"id": "O6uvpzGd5pu"
},
{
"level": 2,
"id": "fdc6uOvgoji"
},
{
"level": 2,
"id": "lc3eMKXaEfw"
},
{
"level": 2,
"id": "jUb8gELQApl"
},
{
"level": 2,
"id": "PMa2VCrupOd"
},
{
"level": 2,
"id": "kJq2mPyFEHo"
},
{
"level": 2,
"id": "qhqAxPSTUXp"
},
{
"level": 2,
"id": "Vth0fbpFcsO"
},
{
"level": 2,
"id": "jmIPBj66vD6"
},
{
"level": 2,
"id": "TEQlaapDQoK"
},
{
"level": 2,
"id": "bL4ooGhyHRQ"
},
{
"level": 1,
"id": "ImspTQPwCqd"
},
{
"level": 2,
"id": "eIQbndfxQMb"
},
{
"level": 2,
"id": "at6UHUQatSo"
}
]
}
moving to the next page only results in the last organisation unit being returned
//https://play.dhis2.org/2.36.3/api/organisationUnits.json?page=2&maxLevel=2&totalPages=true%2Cpage%3D2&fields=id%2Clevel&withinUserHierarchy=true
{
"pager": {
"page": 2,
"pageCount": 27,
"total": 1332,
"pageSize": 50,
"nextPage": "https://play.dhis2.org/2.36.3/api/organisationUnits.json?page=3&maxLevel=2&totalPages=true%2Cpage%3D2&fields=id%2Clevel&withinUserHierarchy=true",
"prevPage": "https://play.dhis2.org/2.36.3/api/organisationUnits.json?maxLevel=2&totalPages=true%2Cpage%3D2&fields=id%2Clevel&withinUserHierarchy=true"
},
"organisationUnits": [
{
"level": 2,
"id": "at6UHUQatSo"
}
]
}
Is this a bug or is there something I’m missing?
Thanks.
Regards
Gift Nnko