Deleting Tracker Records using WEB API

Deleting Tracker Records using WEB API

We can delete DHIS2 Tracked Entity Instances using postman as follows:



Way to delete by Node JS:

let jsonPayload = {
  "trackedEntityInstances": [
    { "trackedEntityInstance": "qWB25lSjfKd" },
    { "trackedEntityInstance": "YGyelJBMeKy" },
    { "trackedEntityInstance": "DiszpKrYNg8" },
    { "trackedEntityInstance": "k4ODejBytgv" },
    { "trackedEntityInstance": "YsKjdOcl9Cd" },
    { "trackedEntityInstance": "wNiQ2coVZ39" }
  ]
} 	

let options = {
    method: 'POST',
    url: "https://play.dhis2.org/2.31.3/api/trackedEntityInstances?strategy=DELETE",
    body: jsonPayload,
    headers: { 
    	'Authorization': "Basic " + new Buffer("admin":"district").toString( "base64" ),
        'Accept': 'application/json',
        'Content-Type': 'application/json' 
    },
	from: {
	  mimeType: 'application/json'
	}
}; // end of options

request(options, function(error, response, body) {
  console.log("Result:  ", response.statusCode);
}			 	

Very simple in curl:


curl -X POST -d @jsonPayload.json -u admin:district -H "Content-Type: application/json"
  "https://play.dhis2.org/2.31.3/api/trackedEntityInstances?strategy=DELETE"

Detail: https://docs.dhis2.org/master/en/developer/html/dhis2_developer_manual_full.html#webapi_tracker_bulk_deletion