I am developing a react app over DHIS2 and data online that is structured like:
indicators: [
{
name: "something",
attributeValues : [ {}],
anotherNode: "anything",
},
{},
{}, ...
]
I am trying to update the whole attributeValues Node. I'm using a fetch request, but getting
405 method not allowed
What do you suppose i'm doing wrong. This is the fetch post request i wrote.
let dataToSend = {
lastUpdated: currentTime,
created: currentTime,
value: newName,
attribute: {
id: indicatorID,
},
};
fetch(`https://www.namis.org/namis1/api/indicators/${id}/attributeValues`, {
body: JSON.stringify(dataToSend),
headers: {
Authorization: basicAuth,
"Content-type": "application/json",
},
method: "POST",
}).then((response) => response.json());
If the question happens to be a duplication, please direct me to the possible already existing solution.
Regards.
POSTis not allowed in the endpoint/api/indicators/ID/attributeValues. You can try to update the whole indicator with aPUTor other ways. The best way to find out what to do is to open developer console and do the same in the interface (add attributeValues to indicator) and see what the network tab in the developer console does.