API query parameter syntax

Jump to solution
swaldie
Community Explorer

I'm working with the Enrollments endpoint, and the live API displays the following request URL when filtering on enrollment type:

.../api/v1/courses/2624/enrollments?type[]=TeacherEnrollment&type[]=StudentEnrollment

The intention being to limit the results to enrollment objects with a type of either TeacherEnrollment OR StudentEnrollment.

And though this syntax appears to be working, can I form this any another way?

E.g., ...?type=TeacherEnrollment,StudentEnrollment&...

0 Likes
1 Solution
jerry_nguyen
Community Contributor

@swaldie 

You need to append it with &paremeter[]=xyz&parameter[]=abc and to filter by enrolment status, append this parameter state[] in your request. E.g.

 

/api/v1/courses/(course id)/enrollments?type[]=TeacherEnrollment&type[]=StudentEnrollment&state[]=active&state[]=invited

 

If you want to get a full list of enrollments for a course, simply send a request to /enrollments without any parameters.

For JSON, you can use Postman and follow the instructions here: https://community.canvaslms.com/t5/Canvas-Admin-Discussion/API-POST-Global-Announcement-to-Specific-...

 

 

View solution in original post

0 Likes