Retrieve datavalue with api

Hello all,

I’m trying to retrieve datavalue with the web api but i’m getting de following error :

{
    "httpStatus": "Conflict",
    "httpStatusCode": 409,
    "status": "ERROR",
    "message": "Data value does not exist"
}

Here is my request

/api/33/dataValues?de=fFvNf25ygzR&pe=202203&ou=JPZThVJtzl1

Regards

Hi @didate,

Do you have a datavalue entered for the given Data Element, period & org unit? If you are using disaggregations in your data entry form, then you need to pass additional parameter ‘co’ to get the data value.

1 Like

Hi @didate
You are right. What version of dhis2 are you using? This might be a bug issue because the same error appears on play even though the parameters are correct and the value does exist.

When using the api/analytics we are able to get the value:https://play.dhis2.org/2.38.1/api/38/analytics?dimension=dx:z7duEFcpApd,pe:202101&filter=ou:DiszpKrYNg8&skipData=false

on the other hand, the api/dataValues returns “Data value does not exist”: https://play.dhis2.org/2.38.1/api/dataValues?ou=DiszpKrYNg8&pe=2021011&de=z7duEFcpApd

Getting support for this. Thank you @didate and @rithvik (:

@didate would you please like to create a jira.dhis2.org bug issue? (and share the link here)

Update:
@rithvik actually got it right! :+1::+1:

@Jason supported this issue and responded that this endpoint requires category option (if you see the api/analytics endpoint it lists the related category options.

If the data element doesn’t have a category option it will work. For example, https://play.dhis2.org/2.38.1/api/dataValues?ou=DiszpKrYNg8&pe=202101&de=f7n9E0hX8qk but the one I mentioned above doesn’t work because we need to mention a co (category option) https://play.dhis2.org/2.38.1/api/dataValues?ou=DiszpKrYNg8&pe=202101&de=z7duEFcpApd&co=psbwp3CQEhs

You might want to review this section in the docs: Individual Data values

Thanks!

Hello @Gassim and @rithvik thank you for your responses.

I will definitely use the analytics API even if I would have preferred to use the raw data.

We’re trying to migrate some datas from old dhis 2 instance to new one.

Regards

1 Like

You’re welcome @didate!

I think you’d be able to get the raw data if you’d add the co in the dataValues endpoint as @rithvik and @jason mentioned.

I remember it was recommended to upgrade the instance itself (or a replicate) when you want to migrate to another instance of a higher version.

Our goal is to migrate part of the data, not all of the instance’s data.

I’m going to continue with the analytics API, it works well. It also allows us to retrieve data for several months at the same time, which reduces the number of requests on the source instance.

Thank you so much