How to update tracked entity instance using

Hi
I have tracked entity instance that I want to update one attribute of this instance using web API
I am using Nodejs

const baseUrl = "http://localhost:8080/api/";
const username = "admin";
const password = "district";
const endpoint = `trackedEntityInstances.json`;

const url = `${baseUrl}${endpoint}`;
    
const data={
    "trackedEntityInstance":"d0hQJiDhJpY",
    "attributes":[
           {
            "attribute": "To4XjKbC43w",
            "value": "3241243"
          },
    ]
 }


 const responseFromDHIS2 = axios.put(url, data, {
        auth: { username, password },
      })
      .then(response => {
        // Handle the response here
        console.log(response.data);
      })
      .catch(error => {
        // Handle any errors here
        console.error(error);
      });

I get the following error
message: “Request method ‘PUT’ not supported”

any help or suggestion

Hi @anaskoara

Usually I always first check it with Postman, if the method will work or exists. In your situation use POST, but you need to post all TEI details. Patching doesn’t work.

Regards

1 Like

how to update tracked entity instance using data query play ground?

How to use the Data Query Playground | DHIS2 Developer Portal here is the documentation.
On the left side put all your payload and choose mutation method.

1 Like