Event Ids are duplicated in events API call with pagination in DHIS

Events GET API call with pagination in DHIS is returning duplicate ids because of which few of the ids are missed in the complete result.

This is causing issue to our custom app as few of the event ids are missed.

API Call: <DHIS_URL>/api/events?startDate=2022-10-31&endDate=2023-01-22&orgUnit=&ouMode=DESCENDANTS&fields=event&pageSize=200&totalPages=true&page=1


  1. This issue is happening only in few servers and working fine with other server with same DHIS version.
  2. With pagesize as 200 and total event count being 4.7k events around 9 event are missed. Same API with pagesize as 50 around 30 events are missed.
  3. With pagesize as 5k, we are able to get all the 4.7k events without any duplicates.

Please help us, if you are aware of any similar issues and any work arounds available for such issues.

Similar issue reported in community: All events inside the enrollment shown duplicated

CC: @Supriya_Muppiri @Gassim

1 Like

Hi @Tarun,

Welcome to the community! Was the solution provided by @Ulanbek successful?

I have not been able to replicate any of the issues mentioned above. Probably updating to 2.37.9 and clearing server and browser cache should solve the issue.

Thank you!

Hello @Gassim,

No, clearing the cache and reloading apps on Data Administration, did not work for us. We did not consider upgrading DHIS as with same/similar DB and same DHIS version in two servers. This issue is reproducible in one server and not in other server.

Thank you!!

1 Like

Maybe this is a DB issue? Could you check for duplicates directly in the DB? If there are duplicates in the DB then they should probably be removed. Make sure to back up before testing. Thanks!

With larger page size, we can get all the results in one page and i don’t see any duplicates in that single page response. So, i am not expecting any duplicates in DB. But i will check from DB side once.

Everything looks okay from DB side. I was able to reproduce the issue in other server also by restoring it with the DB of server which has the issue.

Also saw the code and figured out that pagination is done by adding limit and offset to the query. Results can be repeated by just adding limit & offset and it is recommended to have order by to get results without duplicates based on sql - PostgreSQL - repeating rows from LIMIT OFFSET - Stack Overflow.

I have added “order” api query param as “order=event” and things started working as expected / I don’t see any duplicates after adding “order” query param to the API.

Thank you @Gassim for your timely support.


Hi @Tarun!

Great news to hear and happy you found the solution. Thank you so much for sharing the solution with the community! :slight_smile: If the topic is solved please select the post that solves the problem (your last post probably.)

Thank you!

1 Like