I need to delete enrollments with the following conditions:
I look at this Enrollments - Canvas LMS REST API Documentation but requires enrollment id and using a course endpoint.
Is there any way to perform this task or SIS import is the only option?
Yes, if you also have the sis course id, you can do it with two calls. The first to get the enrolment id, and the second to do the delete.
For example, something like:
Get the id from the returned JSON, and then
Note that you can use things like sis_section_id:SectionId where you need an object's id (Object IDs, SIS IDs, and special IDs - Canvas LMS REST API Documentation).
And if you do not have the course sis id, you can call:
To get the course id (and also the course sis id).
Thanks, I was able to perform the task in two calls. The first call response also provided me the course id, so I dont need to do a third call.
One thing I noticed is that even though I am passing task=delete parameter to the second call, the final result is that user enrollment sits under Completed Enrollments instead of being deleted from the section/course. I am not a UI user entirely, but is this the normal behavior on Canvas?
Um, not sure where Completed Enrolments shows up (I'm not a major UI user either).
If I do a task=delete the enrolment appears to disappear from everywhere I've looked.
If I do not do the task=delete, the enrolment disappears from the course's People, but shows to the user under Past Enrolments.