Showing results for 
Show  only  | Search instead for 
Did you mean: 
Community Participant

Canvas Enrollment Parameters Request issue


I am attempting to make a request to get all completed courses for a given user. I am using PHP and cURL to make my Oauth request for tokens and call. When I run a request against https://<mycanvasintallpath>/api/v1/users/:user_id/enrollments I get the expected list of all active and invited course for that users. When I add the string ?type=StudentEnrollment this also works as expected showing all enrollments where that user is a student. My issue comes when I tried to using any other enrollment parameter : state, role, etc... When I use

https://<mycanvasintallpath>/api/v1/users/:user_id/enrollments?state=active for example i get an error message internal_server_error. I know normally this error occurs when there is a PHP error preventing the program from running but I have no access to the php logs since this is a hosted system.

I have tried making a request against the courses and didn't have any issues using parameters: works as expected.

Has anyone else experienced an issue with enrollments before?

Thank you.

Tags (1)
3 Replies
Community Champion

Hi --

For the enrollments API endpoint, the correct parameter to filter by state is:


so your URL would be something like:


Look carefully at the parameters that are documented for the enrollments API endpoint here:

Enrollments - Canvas LMS REST API Documentation

Some of the parameter names have the square brackets at the end and some do not.


Thank you for that clarification. I didn't consider that an issue since I tried the type parameter, which has the same [], without them and it was working fine so I assumed they were not needed. I will check if this solves my issue.

Community Champion

50581462​ makes a good point.  Some variables use empty brackets, some use brackets with a contained value, and some variables don't use any bracket.

To expand on what he points out, I have also noticed that the doucmentation is sometimes inconsistent.

I found a good one yesterday while working on a script to publish courses, this might be useful for future reference so I'll mention it here:  Courses - Canvas LMS REST API Documentation

When you execute the "Update a course" API call, one of the parameters is documented as "event"

So if you pass "event=offer", the course will be published and if you pass "event=claim" the course will be unpublished.

However, "event" does not work.

I added other variables to the call and was able to tweak other values in the course, so I knew the API call was succeeding, and was scratching my head trying to figure out why I couldn't publish/unpublish a course.

I ended up playing with the syntax and got it to work.

The correct syntax is consistent with the other variables defined, this form of the variable did allow me to publish/unpublis:

  "course[event]=offer" and "course[event]=claim"

If at first your variables don't appear to work in an API call it is worth playing with the syntax.

Maybe this will be useful info for future API endeavors.