API - Set a students enrollment to 'inactive'

Jump to solution
ellington
Community Explorer

Hello,

I'm attempting to 'drop' students from courses through the Canvas API. Currently when I run my drop php code the student is marked as 'Completed' but I would like to set the student as 'Inactive'.

I'm trying to follow the documentation for Conclude, deactivate, or delete an enrollment and pass the inactivate task. I believe the GUI option for this is 'Deactivate'.

Enrollments - Canvas LMS REST API Documentation 

-------------------------------

$response = $client->request('DELETE', 'api/v1/courses/'.$course_id.'/enrollments/'.$enrollment_id ,

                                         [
                                        'headers' => $headers,
                                        'body' => json_encode($enroll_array),
                                         ]);

I'm not sure i'm reading the Docs correctly on how to provide the 'task' for this endpoint. The json body looks like this:

"["inactivate"]"

Thank you for your assistance!

Jeremiah Ellington

Holy Names University

Labels (2)
0 Likes
1 Solution
ellington
Community Explorer
Author

I just resolved my issue! I needed the json to include the task parameter. Strike three for me Smiley Sad. It's always the simple stuff that gets me..

"{"task":"inactivate"}"

Thanks again!!

Jeremiah Ellington
Holy Names University

View solution in original post