I am trying to create events
linked to trackedEntityInstances via the API.
The below payload works great when I send a POST
request to /api/33/events
. However, when mapping related dataValues
, I’m finding that I have to use the string value for the option value (e.g., acute_abdomen
) instead of this option’s UID (Z3a44uyRxNB
). For my specific use case, this might be problematic down the line as many teams might be copying this dhis2 configuration and localizing it to their context… we fear the option values might change, but we can count on the option UIDs to be consistent across locations and languages. Therefore, is there a way to import dataValues via the API using the option value Ids instead of string values?
This below payload works well and the corresponding option value label Acute abdomen
displays correctly to the user on the front end (in both english and french).
{
"program": "uGHvY5HFoLG",
"orgUnit": "l22DQq4iV3G",
"programStage": "hfKSeo6nZK0",
"trackedEntityInstance": "cPQDZSzEuiu",
"eventDate": "2023-07-26T00:00:00.000",
"dataValues": [
{
"dataElement": "ZTSBtZKc8Ff",
"value": "acute_abdomen" //here we send the option coded string value
}
]
}
This next payload does not work when I send the option Id Z3a44uyRxNB
as the value
… is there any attribute I can add to this payload (e.g., optionSetId
?) in order to use option Ids instead of the string values?
{
"program": "uGHvY5HFoLG",
"orgUnit": "l22DQq4iV3G",
"programStage": "hfKSeo6nZK0",
"trackedEntityInstance": "cPQDZSzEuiu",
"eventDate": "2023-07-26T00:00:00.000",
"dataValues": [
{
"dataElement": "ZTSBtZKc8Ff",
"value": "Z3a44uyRxNB" //using the option Id instead of string value
}
]
}