/myenrollments/{orgUnitId} returns 404 if learner is only in EXPIRED OrgUnit

Carlos.A.313
Carlos.A.313 Posts: 2 🌱
edited April 14 in Development

Hi all,

I’m working on a custom homepage widget in Brightspace that shows a learner’s course progress using status icons. Each course is linked to up to four OrgUnitIDs:

  • Main course (e.g. ODS214)
  • ENROLLED (e.g. ODS214-ENROLLED)
  • COMPLETE (e.g. ODS214-COMPLETE)
  • EXPIRED (e.g. ODS214-EXPIRED)
  • Optional: GRANDFATHERED (e.g. ODS214-GRANDFATHERED)

The widget uses GET /d2l/api/lp/1.9/enrollments/myenrollments/{orgUnitId} to dynamically check enrollment in each OrgUnit and assign the correct status icon. It works great — except in one scenario:

Problem:

If the learner is only enrolled in the EXPIRED OrgUnit (e.g. 11323) and not also in the ENROLLED or COMPLETE OrgUnits, then the API returns a 404 Not Found.

  • The learner is enrolled in the EXPIRED OrgUnit (confirmed in LMS).
  • The API call still returns 404.
  • In our LMS, learners are only enrolled in one OrgUnitID per course at a time (due to Intelligent Agents).

This causes the widget to default to a “Not Enrolled” state, even though the EXPIRED OrgUnit enrollment exists.

What works:

If the learner is enrolled in both EXPIRED and either ENROLLED or COMPLETE, the red Expired icon displays correctly.

Sample logic (simplified):

const expired = course.expiredId
? await CSPS.get.amIenrolledOrgUnit(course.expiredId)
: false;
Questions:
  1. Is the 404 response expected behavior when a learner is only enrolled in an OrgUnit with a label like “EXPIRED”?
  2. Could this be related to how OrgUnits are flagged or categorized in Brightspace?
  3. Is there any caching or filtering layer in the myenrollments endpoint that could cause certain OrgUnits to be hidden?

Any guidance or confirmation would be much appreciated! Happy to provide further code or screenshots if needed.

Thanks,
Carlos.

Tagged:

Best Answer

  • Carlos.A.313
    Carlos.A.313 Posts: 2 🌱
    Answer ✓

    Just posting a quick update in case it's helpful to others.

    I’ve resolved the issue on my end by rebuilding the widget logic from scratch and testing each scenario using a test learner account in PROD. After several iterations and debugging with console.log outputs, the status icons - including the EXPIRED case - are now displaying correctly based on OrgUnit enrollment.

    In our case, the 404 from /myenrollments/{orgUnitId} turned out to be expected behavior, and the solution was to adjust how we were prioritizing status logic in the code.

    Sharing here in case others run into a similar issue.

    Carlos.