Event data

Guys, Trying to export event data in csv format but couldn’t, it downloads blank file.
v2.33 and the url used is : localhost/dhis2/api/29/eventReports/id/data.csv

Appreciate your advice

1 Like

Hello @Shady

The API endpoint ‘api/29/eventReports/id’ points to the metadata of the specific event report that you want to save. The metadata doesn’t contain any data, it only contains the information on how to generate a report. The best way is to use the Event Reports app > Download > CSV (.csv).

If you are a programmer and want to somehow download data through the API, the endpoint to download data is (api/29/analytics/events/). There are different parameters you need to provide in order to generate the data, you can look at the documentation at https://docs.dhis2.org/master/en/developer/html/webapi_event_analytics.html

2 Likes

Hi @Shady, to follow up on @Melaeke’s point, you can find the parameters used to generate a specific event report by going to Event reports app > Download > HTML. That will open the event analytics query in API in a separate tab. One trick, you can change the extension from “.html+css” to “.csv” in the browser and it will download as CSV.

Example Event Report:
https://play.dhis2.org/2.33.3/dhis-web-event-reports/index.html?id=R4wAb2yMLik

Download > HTML

Change extension from “events/query/eBAyeGv0exc.html+css?” to “events/query/eBAyeGv0exc.csv?”

1 Like

Thank you both @Melaeke and @brian :slightly_smiling_face:
it worked perfectly

2 Likes

Hi Shady!
I change this link : https://dhis-linkagesci.fhi360.org/api/29/analytics/events/query/tAOHpVITIAi.html+css?

To: https://dhis-linkagesci.fhi360.org/api/29/analytics/events/query/tAOHpVITIAi.csv

but it doesn’t work for me