How to read data values for more than one data element and organisation unit using the dataValues endpoint of the WebAPI

I want to retrieve data values for a given period for all children and grand children of a top level orgUnit for a fixed list of data elements using the dataValues resource of the WebAPI. I don’t want to import the whole dataset, just the data captured by the data elements I’m interested in. Am not sure this is possible.
I successfully imported the dataelements and corresponding category combos from one dhis2 instance to another. Now i want the data values for only those data elements imported using the WebAPI.

Is there a way to specify more than 1 data element identifier in the Data values query parameters?
I’ve tried using;

/api/26/dataValues.json?de=If0pYdi5PuD&de=A2oyRqZ11uI&pe=2018Q3&ou=HpJYuf9iyz2

but then i get this;

{“httpStatus”:“Conflict”,“httpStatusCode”:409,“status”:“ERROR”,“message”:“Illegal data element identifier: If0pYdi5PuD,A2oyRqZ11uI”}

Is it also possible to read data for the children and grandchildren of a parent orgUnit just like one would do using the dataValueSets resource

/api/26/dataValueSets.json?..&orgUnit=aDq8sOcS9r6&children=true

Any help here.

1 Like

I figured it out. Both /api/26/dataValueSets end point and /api/26/dataValues endpoint according to the documentation don’t provide for that. Forgive me I was so used to those resources.

However, the The analytics dataValueSet resource available at the /api/26/analytics/dataValueSet endpoint allows for returning aggregated data in the data value set format - what i wanted. See documentation here

I can then use the Data (dx), Period (pe), Organisation unit (ou) dimension query parameters to control data, period and orgUnits to get what i want. I also include the category dimension in the query string (dimension=co) to make sure my payload has data broken down by category option combinations rather than totals;

/api/26/analytics/dataValueSet.json?dimension=pe:2018Q4;2019Q1dimension=ou:LEVEL-5;yuo5ielNL7W&dimension=dx:gQEi3XsjoW1;yIBTOW1RFLA&dimension=co

I hope this can help someone out there who loves do play around with the API to get just about anything.:smiley:

Cheers!

1 Like

Thanks you for the feedback @paleu256!

1 Like