Tracked Entity instances import format

Hello,

We have a need to import tracked entity instances, we are following below format, but it is not working. No data uploaded and can be seen in capture app. Can you please help. We are using Import/Export app for this.

{
“trackedEntityInstances”: [
{
“trackedEntity”: “kePSzLBpvOy”,
“orgUnit”: “LNuGy8jKPtJ”,
“attributes”: [
{
“attribute”: “G7Qm2MjV51T”,
“value”: “1”
},
{
“attribute”: “SFDiMBv2dAt”,
“value”: “5”
},
{
“attribute”: “vEIGCzMowWk”,
“value”: “TPL6”
},
{
“attribute”: “fxA3rRbdM7k”,
“value”: “TPL6”
}
],
“enrollments”: [
{
“program”: “hZDbclr7Ka1”,
“enrollmentDate”: “2025-03-21”,
“incidentDate”: “2025-03-21”
}
]
}
]
}

Hi @ramavat

Sorry, I’m trying to repeat this issue in the play.dhis2.org instances but I can’t reproduce the issue. Using the Import/Export app, I exported TEIs list, kept one TEI and then reimported the JSON but it’s not showing me any error.

May you provide us with additional details such as what is the error that you see?Thanks!

@Gassim Thank you for your input. So we need to refer to the same format that we get from export? I am not sure about the JSON format, I have tried the same as in my earlier post, but it didn’t work and no errors reported also.

Hi @ramavat

When using JSON, I think using the same format as the export should work because it’s the one working for me when I export it from the Import/Export app and then reimport.

You can test that yourself on any of the play.dhis2.org instances. Please tell if it actually doesn’t work for you.

Please did you also check the Network tab and the Console (F12)?

Thanks!

Hi @ramavat

Which version of DHIS2 are you using?

For the latest version, you should use “trackedEntities” and NOT “trackedEntityInstances” which has been deprecated for latest versions.

Also, it is a good idea, as Gassim suggeted, to export an existing TEI to double check the expected format.

Hope this may help.

Thanks, I will try it out and will keep you posted.

One more question, Is there any tool we can use to generate the specific format of json, because we wanted import almost 50+ TEI at a time, so creating JSON manually will be difficult.

Thanks,
Hiral

Hi @ramavat

To generate TEI, you can etiher use:

  • Programming skills to generate the TEIs in json
  • Postman Collections to generate and send APIs requests based on an excel file
  • BulkLoad DHIS2 application, which generates an Excel template file based on your tracker Program and enables you to import from this excel template.
    Have a good day