Events creation generate 409 Tracked entity instance: is not enrolled in program when it actually is


I am creating a django pusher to DHIS2 but I am facing a strange issue

I first create a TEI with enrollment to program 1 included

When I add event on program 1 but I got 409 Tracked entity instance: is not enrolled in program but when I check the enrollment I can clearly see it:

POST on http://localhost:8080/api/events that get the 409
{"events": [{"program": "IR5BiEXrBD7", "programStage": "DVRNDUNwI9s", "trackedEntityInstance": "T4UQKgHLi8n", "orgUnit": "BI8X3rJHbUa", "status": "COMPLETED", "eventDate": "2012-09-19"}]}

But http://localhost:8080/api/enrollments?ou=BI8X3rJHbUa gaves
<page>1 </page>
<pageCount>1 </pageCount>
<total>0 </total>
<pageSize>50 </pageSize>
<enrollment lastUpdated=“2021-03-02T19:30:41.807” trackedEntityType=“EoBGArVCQ69” created=“2021-03-02T16:41:09.591” orgUnit=“BI8X3rJHbUa” program=“IR5BiEXrBD7” enrollment=“T4UQKgHLi8n” trackedEntityInstance=“T4UQKgHLi8n” orgUnitName=“Uhuru”>
<enrollmentDate>2012-09-17T00:00:00.000 </enrollmentDate>
<incidentDate>2012-09-17T00:00:00.000 </incidentDate>

the weirdest thing is that pushing enrollment with the event inside worked for another program

Any Idea of what I missed ?

DHSI2 2.35 / Tomcat 8.5 / postgres 11

Thanks in advance

Dear I found the issue which was really stupid,
For my program 2, I was sending the event within the enrollment, so having the enrollment “COMPLETED” was not an issue but it was in my other program because you cannot add event on a closed enrollment (really basic issue)

herefor other the minimal actions if your api send the event later


1 Like