Using relative period types with DHIS2 API

Hi everyone!!
This is regarding some issues i faced while researching the DHIS2 API. I wanna clarify few things on the dhis2 relative period types. (I was working on the openmrs dhis2 connector module which is used to post aggregate data from OpenMRS to DHIS2)

I read your api documentation and according my understanding, the /api/dataValueSets endpoint uses a request payload like following:

  "dataSet": "iReVg2xgFPL",
  "completeDate": "2018-06-06",
  "period": "201712",
  "orgUnit": "bVo3BRA2D2a",
  "dataValues": [
    { "dataElement": "ta8v9gj6aQC", "value": "10" },
    { "dataElement": "yQfHIwxvCmb", "value": "20" },
    { "dataElement": "CRueZPFX52M", "value": "30" }

I saw that we can use any of the static period types (with the correct period) listed in this documentation: 1.4 Date and period format

My problem is, how can we use the relative period types to send data to dhis2 using the api. Is it possible to use the relative period types with the
/api/dataValueSets endpoint?

Thanks in advance😊

1 Like

Hi @piumal1999!

As the documentation mentions, you can use relative periods in some parts of the API, like for the analytics resource, in addition to fixed periods.

However, using relative periods with /api/dataValueSets doesn’t seem to be supported at the moment. If this is a requirement, it could be requested as a feature on DHIS2 JIRA.

To work with the analytics resource, please check the docs here. You’ll see an example like this one:

To query using relative periods and organisation units associated with the current user you can use a URL like this:


Hope this helps!


@debora Thank you so much for your quick response.

1 Like