Can’t export events for a specific period by api: occuredBefore is not working on version 2.40

I’m am trying to export events using the new endpoint /api/tracker/events on version 2.40 for a specifc period using occuredBefore and occuredAfter.

api/tracker/events.json?orgUnit=cfCqpzvsgXZ&programStage=k0wtavEb314&occurredBefore=2023-10-01&ouMode=DESCENDANTS 

But occuredBefore and occuredAfter are not working??? Data return is the only the latest data. I used it as i saw in the documentation but it is not working. HELP

Hi @lens_Kamdem

I’m testing the API request to get events using the dhis2.stoplight.io and I suggest that you could test the API request there. I actually see the api/events endpoint so you might want to test that too. Please see the demo here:
List Events | DHIS2

You can use the form to the right to see and fill in the parameters that are available and working, test using the demo server, and see the response. After that you can copy the request and modify it for your own instance. Please let me know if this helps or if it doesn’t!

Thanks!

Thought my previous response might not be exactly helpful since it’s afterall using the deprecated endpoint and the recommended approach is to use the latest and supported endpoint, so you are on the right path; however, I tested all the parameters in the demo instance and it seems they are working properly.

Please see the following request instance/api/tracker/events.json?orgUnit=ImspTQPwCqd&ouMode=DESCENDANTS&occurredBefore=2022-04-30&occurredAfter=2022-03-31&programStage=lST1OZ5BDJ2

BTW, in your request I can only see occurredBefore and I don’t see occurredAfter, maybe you would like to add that?

I would like to hear how you decide to solve the issue! Thanks!