Paging of api-results

I run into some really strange results when I call the API using this (semiofficial?) dhis2 python wrapper

I expected that an unpaged get would give me all the data:
api.get('organisationUnits', params={'paging': False, 'fields': 'id,code,name'})

However (using play.dhis2.org/40.2.2) - the returned JSON string ends like this:

{'code': 'OU_204876', 'name': 'Dia CHP', 'id': 'qHBTf9A89xW'}, {'code': 'OU_222737', 'name': 'Diamei MCHP', 'id':

Note that there is no value for ‘id’ here.

However, if I ask for a large dataset
api.get('organisationUnits', params={'pagesize': 1000, 'fields': 'id,name,code'})

then I get all orgUnites as well as a propper ending of the string:
{'code': 'OU_233393', 'name': 'Baoma MCHP', 'id': 't52CJEyLhch'}]}

Is this on purpose or should it be noted in the docs that you should always page unless your resultset is really small?

Hi,

Perhaps this is an issue with the python library, do you see the same issue when you call the API directly? https://dhis2.stoplight.io/docs/dhis2

1 Like

What a great resource Stoplight seem to be @Rene: Thanks! I was not aware of it - it seems to be a great supplement (for some a replacement?) for the core docs

I have now tried to call the api from a browser, and indeed there is no truncating of the JSON string there.

So this seem to belong somewhere in python-land …

1 Like

Great to hear it’s not the API!

Stoplight is a supplement to the API docs. We do link it from the Developer portal but we could do a better job at sharing the resource!

Perhaps you could submit a PR to the Python library to fix the issue, or raise an issue on the repository page.

A second option would be to use the OpenAPI spec of DHIS2 to generate a python library directly, as the repository does seem to be out of date for a few years

3 Likes