DETAIL POST
I read in the doc that I can send individual data values as a JSON payload using the following resource using Content-Type: application/json
like
{
"dataElement": "fbfJHSPpUQD",
"categoryOptionCombo": "PT59n8BQbqM",
"period": "202201",
"orgUnit": "DiszpKrYNg8",
"value": "10",
"comment": "OK"
}
So far this works fine in my custom app. But when I created a data element with category option combination, I run into trouble.
How I send the Payload
I am using a hard-coded token in my local env. But I do comment out the Authorization line when sending in production.
submitToServer = async (row, coc) => {
const payload = {
"dataElement": "B4rfhmYXmKk",
"categoryOptionCombo": "xrfgZqa34U0",
"period": "WthyJC7lw2W",
"orgUnit": "MfghrZAzhdw",
"value": 33,
"comment": ""
}
try {
await axios.post(`${dhis2BaseURL}/dataValues`, payload, {
headers: {
// 'Authorization': `Basic ${token}`,
'Content-Type': 'application/json'
}
})
.then(res => {
console.log('res.status', res.status)
})
.catch(err => {
console.error(err);
});
} catch (error) {
te(`There is an error! Please try again.`);
}
}
Like I said this work fine except when I am sending this for a dataset with DE with COC.
After I capture the data, I check the datavalue table in the database and the record is there
But when I open the form in Data Entry (Beta) App the form didn’t fetch the filled form.
When I also try to get the data with Data Visualizer App, nothing was returned. However, when I capture the data using the Data Entry (Beta) App, the data replaced the one I have in the database and start showing up in the Data Entry (Beta) App and the Data Visualizer App.
I doubt though if this is related to the custom app. I noticed that another dataset I created with COC work fine.