Enrollments POST API failure

Issue summary:

API: <dhis_url>/api/enrollments

The above post API call is getting failure responses inconsistently for the custom client app.
During this issue the API response code is 201 with response error message “Program is not assigned to this Organization Unit:”.

Description:

  1. The system should have some levels (at least 2 levels) of organisation units configured already to reproduce the issue.

  2. Create a new organization unit (a child organization unit) to a parent that has other childs having a tracker program attached to them. Attach the same tracker program to the newly created child organization unit.

  3. Create a new case with an event for the tracker program attached, select the enrolling organisation unit value to be a newly created organisation unit.

  4. While creating enrollments POST API call returned response code 201 but with an error message “Program is not assigned to this Organisation Unit: <newly_created_orgUnitId>”.

  5. Then events POST API call failed with status code 409 and error message “Tracked entity instance: <trackedEntityInstance_id> is not enrolled in program:

Observation:

  • Immediate use of the newly created organization unit seems to trigger the issue. We are not seeing the issue after a day with the same steps mentioned above.
  • Sometimes running maintenance from data administration is also resolving the issue.
  • We observed this issue after upgrading to DHIS 2.37.8.1.

cc: @Gassim @Tarun @phil

1 Like

Hi @Supriya_Muppiri,

Have you been able to fix the problem?

Did you try from any external application such as Postman, CURL, etc.? Can you provide the entire response code?

Thank you

1 Like

Hi @julhas ,
No we haven’t fixed the problem yet. We found a workaround which we mentioned at the end of this reply.
We have used POSTMAN to make the API call but received the same error.
Here is the response we have received:

{
  httpStatus: 'Created',
  httpStatusCode: 201,
  status: 'ERROR',
  message: 'An error occurred, please check import summary.',
  response: {
    responseType: 'ImportSummaries',
    status: 'ERROR',
    imported: 0,
    updated: 0,
    deleted: 0,
    ignored: 1,
    importOptions: {
      idSchemes: {},
      dryRun: false,
      async: false,
      importStrategy: 'CREATE_AND_UPDATE',
      mergeMode: 'REPLACE',
      reportMode: 'FULL',
      skipExistingCheck: false,
      sharing: false,
      skipNotifications: false,
      skipAudit: false,
      datasetAllowsPeriods: false,
      strictPeriods: false,
      strictDataElements: false,
      strictCategoryOptionCombos: false,
      strictAttributeOptionCombos: false,
      strictOrganisationUnits: false,
      requireCategoryOptionCombo: false,
      requireAttributeOptionCombo: false,
      skipPatternValidation: false,
      ignoreEmptyCollection: false,
      force: false,
      firstRowIsHeader: true,
      skipLastUpdated: false,
      mergeDataValues: false,
      skipCache: false,
    },
    importSummaries: [
      {
        responseType: 'ImportSummary',
        status: 'ERROR',
        importOptions: {
          idSchemes: {},
          dryRun: false,
          async: false,
          importStrategy: 'CREATE_AND_UPDATE',
          mergeMode: 'REPLACE',
          reportMode: 'FULL',
          skipExistingCheck: false,
          sharing: false,
          skipNotifications: false,
          skipAudit: false,
          datasetAllowsPeriods: false,
          strictPeriods: false,
          strictDataElements: false,
          strictCategoryOptionCombos: false,
          strictAttributeOptionCombos: false,
          strictOrganisationUnits: false,
          requireCategoryOptionCombo: false,
          requireAttributeOptionCombo: false,
          skipPatternValidation: false,
          ignoreEmptyCollection: false,
          force: false,
          firstRowIsHeader: true,
          skipLastUpdated: false,
          mergeDataValues: false,
          skipCache: false,
        },
        description:
          'Program is not assigned to this Organisation Unit: <orgUnitId>',
        importCount: { imported: 0, updated: 0, ignored: 1, deleted: 0 },
        conflicts: [],
        reference: <referenceId>,
        events: {
          responseType: 'ImportSummaries',
          status: 'SUCCESS',
          imported: 0,
          updated: 0,
          deleted: 0,
          ignored: 0,
          importSummaries: [],
          total: 0,
        },
      },
    ],
    total: 1,
  },
};

Observations:

  1. Although we received 201 as response code for this API call, there is an import error in Import summaries.

Workaround:

  1. This API is getting passed after clearing application cache from DHIS UI → Maintenance → Clear Application cache or when we hit ‘<DHIS_URL>/api/maintenance’ first before making the enrollments POST API call.
1 Like