API to get sections information doesn't return enrollments

Jump to solution
VicKovacs
Community Member

Hi,
I am trying to get a list of enrollments (all participants including faculty and students) in a section.  The token should be privileged to do this, do I doubt that's the problem.

When listing students in a section, everything looks fine:

curl --location
--request GET 'https://ouruniv.instructure.com/api/v1/sections/1642107?include=students' \
--header 'Authorization: Bearer TokenGoesHere' \
--header 'Cookie: CookiesGoHere'

{
    "id"1656207,
    "course_id": 7814027,
    "name""SU-22-BIOL-350-RN7A PATHOPHYSIOLOGY",
    "start_at"null,
    "end_at"null,
    "created_at""2022-03-30T21:20:51Z",
    "restrict_enrollments_to_section_dates"null,
    "nonxlist_course_id"null,
    "sis_section_id"null,
    "sis_course_id""SU-22-BIOL-350-RN7A-OnL",
    "integration_id"null,
    "sis_import_id"null,
    "students": [
        {
            "id"4172720,
            "name""XXXXXXXX",
            "created_at""2022-04-21T20:58:00-04:00",
            "sortable_name""XXXXXXXX",
            "short_name""XXXXXXXX",
            "sis_user_id""XXXXXXXX",
            "integration_id"null,
            "sis_import_id"XXXXXXXX
        },
. . .
    ]
}

 

But when I run enrollments (I need faculty listed as well as students), nothing shows up:

curl --location
--request GET 'https://ouruniv.instructure.com/api/v1/sections/1642107?include=enrollments' \
--header 'Authorization: Bearer TokenGoesHere' \
--header 'Cookie: CookiesGoHere'

{
"id": 1642107,
"course_id": 1402774,
"name": "SU-22-BIOL-350-RN7A PATHOPHYSIOLOGY",
"start_at": null,
"end_at": null,
"created_at": "2022-03-30T21:20:51Z",
"restrict_enrollments_to_section_dates": null,
"nonxlist_course_id": null,
"sis_section_id": null,
"sis_course_id": "SU-22-BIOL-350-RN7A-OnL",
"integration_id": null,
"sis_import_id": null
}

Any idea what could be causing this?  I tried "enrollment" and "enrollments" and hopefully won't have an embarrassing petition for help with a misspelled word.

TIA.

0 Likes
1 Solution
JeffW
Instructure Alumni
Instructure Alumni

Hi @VicKovacs!

When returning section enrollments via API, teacher enrollments are not going to be included.

It seems that what you are going to want is the enrollment API, where you can add a parameter for a specific sis_section_id to be returned. You can then filter that enrollment endpoint to include StudentEnrollment and TeacherEnrollment.

It would come out looking something like this:

https://yourinstance.instructure.com/api/v1/courses/course_id:/enrollments?sis_section_id[]=sis_section_id:&type[]=StudentEnrollment&type[]=TeacherEnrollment 

View solution in original post

0 Likes