Aaron Bahmer

API Enrollment management in Crosslisted courses/sections

Blog Post created by Aaron Bahmer on Jun 18, 2019

I love it when asking a question prompts me to think about and reasearch the actual answer; since I had already typed most of this posting when the solution came to me, I decided to complete it anyway. The topic above is answered herewithin!

 

When managing user enrollment using the API, I have scripts set up to deal with student "adds" and "deletes/withdrawls" by our SIS. These work well until you bring crosslisted sections into the picture.

 

Active Enrollment Endpoint: POST /api/v1/sections/:section_id/enrollments
This endpoint works for crosslisted sections because it is based on the Section_ID which is associated with another Course_ID in the crosslist process.

 

Ended Enrollment Endpoint: DELETE /api/v1/courses/:course_id/enrollments/:id

For crosslisted sections, this endpoint fails because the section in which the student is enrolled is no longer tied to its original Course_ID. Indeed, the course still exists, but the student isn't currently enrolled in that course, thereby failing the API call because "The specified resource does not exist."

 

Solution:
There is an API endpoint where I can use a Section_ID to determine its associated Course_ID. For all enrollment deletes, use this endpoint, first, to determine the correct course from which to actually delete the enrollment, then use the endpoint above to delete the enrollment.

 

Section Information Endpoint: GET /api/v1/sections/:id
The base response from this endpoint provides the course_id and sis_course_id of the course with which it is associated. Use either of these in the DELETE endpoint above

Outcomes