The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December. Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
Using Powershell. I can get a list of 851 enrolled users in this course and section:
$result = Invoke-RestMethod -Method GET -uri "https://XXXX.instructure.com/api/v1//courses/508/sections/579" -header $headers -body @{include = "students";enrollment_role_id = 'StudentEnrollment'}
$result.students.count
851
This includes lots of students who have enrollment type "completed" when looking at the GUI for this section.
When I try to refine my search by adding enrollment_state = "completed" to the body, we still get 851 students.
$result = Invoke-RestMethod -Method GET -uri "https://XXXX.instructure.com/api/v1//courses/508/sections/579" -header $headers -body @{include = "students";enrollment_role_id = 'StudentEnrollment';enrollment_state = "active"}
$result.students.count
851
I think I'm missing something about how enrollments work in canvas or how the body works. Any one able to help out with a valid command for returning only active, enrolled users in a course's section?
Hi @PeterStromberg,
Are you trying to list students in a section or students in a course? The sections API documentation doesn't include some of the parameters you're trying to use (enrollment_state, enrollment_role_id), which I think is why you're not seeing any changes.
I think what you may want to use is the enrollments API instead (https://XXXX.instructure.com/api/v1/sections/579/enrollments ), which has the parameters you seem to need (type[]='StudentEnrollment';state[]='active').
I hope this info helps point you in the right direction!
-Chris
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in