Retrieving Files via /dataValues/files

The documentation states that file resources can be retrieved but the /api/dataValues/files endpoint doesn’t return anything. It also states that mirroring the query parameters as they would be for the data value itself. What does this mean exactly–what are the parameters?

To reproduce

  1. Add a “file” data element to an aggregate data set
  2. Upload a csv or other via the data entry app
  3. Query the file resource UID which is stored in the “value” property - https://play.dhis2.org/2.37.7.1/api/dataValueSets.json?dataSet=DATASET-UID&period=YYYYMM&orgUnit=OU-UID
  4. Request the file via https://play.dhis2.org/2.37.7.1/api/dataValues/files/FILE-RESOURCE-UID

The data value can now be retrieved as any other but the returned data will be the UID of the file resource. In order to retrieve the actual contents (meaning the file which is stored in the file resource mapped to the data value) a GET request must be made to /api/dataValues/files mirroring the query parameters as they would be for the data value itself. The /api/dataValues/files endpoint only supports GET requests.

Hi @chase.freeman ,

I just tired this out on play demo.
I have uploaded a file for “Child Health” in “Sierra Leone” org unit for “July 2022”.
Here is the API call I have used to fetch the file

https://play.dhis2.org/2.37.7.1/api/dataValues/files?de=wvWhlG12uSD&pe=202207&ou=ImspTQPwCqd

So you need to pass in de (DE UID), pe (Period). & ou (Org Unit UID) to get the file.

Thanks,
Rithvik

2 Likes

“Hi, Hello” :grin: Thanks @rithvik - that solves my issue and my question about what parameters are needed.

Best,
Chase

1 Like

I find it very frustrating that the parameters do not align with the other aggregate parameters like for dataValueSets (dataSet, period, orgUnit) and instead use (de, pe, and ou). Also org unit groups are not supported, and I find it strange that data element is required and not data set - since data elements are designed to be re-usable across data sets/ou/periods.