Importing TEI

Hi Everyone,

I am trying to import Tracked entity instances into DHIS using a JSON file in the import-export app but I Keep getting this error
image

Any ideas on how to resolve this?

Thank you.
Otini

Hey @Otini ,

Does your payload start with “trackedEntityInstances”?

{ 
    "trackedEntityInstances": [ 
        {... } 

    ]
} 

Gintare

Hey @Gintare ,

Yes it does.

Look something like this:

[
{
“trackedEntityInstances”: {
“created”: “2021-03-08T22:22:29.611”,
“orgUnit”: “BonurZzxVVE”,
“createdAtClient”: “2021-03-08T22:22:29.611”,
“trackedEntityInstance”: “”,
“lastUpdated”: “2021-03-08T22:22:29.611”,
“trackedEntityType”: “WAvW16a6B4r”,
“lastUpdatedAtClient”: “2021-03-08T22:22:29.611”,
“inactive”: false,
“deleted”: false,
“featureType”: “NONE”,
“attributes”: [
{
“lastUpdated”: “2021-03-08T00:00:00.000”,
“storedBy”: “Otini”,
“displayName”: “Officer Email Address”,
“created”: “2021-03-08T00:00:00.000”,
“valueType”: “EMAIL”,
“attribute”: “fETjfbSGeD6”,
“value”: “xxxu@gmail.com
},
{
“lastUpdated”: “2021-03-08T00:00:00.000”,
“storedBy”: “Otini”,
“displayName”: “Officer Phone Number”,
“created”: “2021-03-08T00:00:00.000”,
“valueType”: “PHONE_NUMBER”,
“attribute”: “ZeEziZjTFOS”,
“value”: 71514525
},
{
“lastUpdated”: “2021-03-08T00:00:00.000”,
“storedBy”: “Otini”,
“displayName”: “Officer Name”,
“created”: “2021-03-08T00:00:00.000”,
“valueType”: “TEXT”,
“attribute”: “JnD3uyIYL3s”,
“value”: “Name One”
}
]
}
},

@Otini ,

Import doesn’t work because the payload is not a valid JSON payload. “trackedEntityInstances” is an array, and should be inside an object, not array. Try this:

{
	"trackedEntityInstances": [
		{
			"created": "2021-03-08T22:22:29.611",
			"orgUnit": "BonurZzxVVE",
			"createdAtClient": "2021-03-08T22: 22: 29.611",
			"trackedEntityInstance": "",
			"lastUpdated": "2021-03-08T22: 22: 29.611",
			"trackedEntityType": "WAvW16a6B4r",
			"lastUpdatedAtClient": "2021-03-08T22: 22: 29.611",
			"inactive": false,
			"deleted": false,
			"featureType": "NONE",
			"attributes": [
				{
					"lastUpdated": "2021-03-08T00: 00: 00.000",
					"storedBy": "Otini",
					"displayName": "OfficerEmailAddress",
					"created": "2021-03-08T00: 00: 00.000",
					"valueType": "EMAIL",
					"attribute": "fETjfbSGeD6",
					"value": "xxxu@gmail.com"
				},
				{
					"lastUpdated": "2021-03-08T00: 00: 00.000",
					"storedBy": "Otini",
					"displayName": "OfficerPhoneNumber",
					"created": "2021-03-08T00: 00: 00.000",
					"valueType": "PHONE_NUMBER",
					"attribute": "ZeEziZjTFOS",
					"value": 71514525
				},
				{
					"lastUpdated": "2021-03-08T00: 00: 00.000",
					"storedBy": "Otini",
					"displayName": "OfficerName",
					"created": "2021-03-08T00: 00: 00.000",
					"valueType": "TEXT",
					"attribute": "JnD3uyIYL3s",
					"value": "NameOne"
				}
			]
		}
	]
}
1 Like

Hi @Gintare

This worked thank you very much.
Regards,

2 Likes