Unable to enroll tracked entity instances or update TEIs via the web API

Hi everyone - I have a payload that I am posting to my DHIS2 instance (curling via my command line) to create and enroll tracked entity instances in one post request. Example curl:
curl -X POST -H "Content-Type:application/json" -d @teipayload.json -u admin:password https://myserver/api/trackedEntityInstances

Issue 1
I am able to (a) successfully create a Tracked Entity Instance, but (b) fail to insert the related enrollment data. For the enrollment import, I am getting the error message:

**"conflicts":[{"object":"Attribute.attribute","value":"Missing mandatory attribute HA0tSkhQSzU"**}

The attribute HA0tSkhQSzU is included in my payload (in the TEI array of attributes), but this error message seems to suggest it also needs to be included as an attribute for Enrollment? But if this is a TEI attribute (and is included in my payload), I’m wondering why this error might be thrown when posting enrollment data?

With the same payload format, I have no issue posting to the DHIS2 Play instance and create & enrolling TEIs.

Issue 2
When I try to post my data with a CREATE_AND_UPDATE strategy to update the TEI I was able to create in the above step, it is trying to create a new TEI (instead of updating this existing one). Can I not update a tracked entity item with the same payload so long as I add the CREATE_AND_UPDATE strategy? The documentation seems to suggest so, but I cannot get it to work…

Example curl:
curl -X POST -H "Content-Type:application/json" -d @teipayload.json -u admin:password https://myserver/api/trackedEntityInstances?strategy=CREATE_AND_UPDATE

My DHIS2 instance is on version 2.28. Appreciate any help or ideas!


Hi. On issue 2, have you included the tei uid in the payload?

1 Like

Thanks for the reply! I have included a unique identifier field (a custom unique attribute - farmer ID). But must I include the DHIS2 uuid for update requests?

1 Like

Hi Aleksa,

Did you find any solution for issue 1.I am facing the same issue.Please help me if solution is there.