cancel
Showing results for 
Search instead for 
Did you mean: 
akshya
Surveyor

Enforcing Scopes causing missing Data in Course Users' Enrollments call

Hi There

I develop an application that uses Canvas' REST APIs to get information on Courses, Users, Enrollments, etc. Generally, I've been developing my application with a Developer Key which doesn't enforce any scopes. I wanted to make sure that my application worked correctly with scopes enabled, but I've found that this is causing some issues for one of my endpoints.

In particular, I am using the List Users in Course endpoint (https://canvas.instructure.com/doc/api/courses.html#method.courses.users)

I am making the API request to get the users in a course, as well as their enrollment information.

GET /api/v1/courses/{course_id}/users?include[]=enrollments

Example API request on a sandbox environment: https://qwickly.instructure.com/api/v1/courses/9/users?include[]=enrollments

When scopes are NOT enforced, I am getting a response that includes the enrollment information. Example response:

{"id":16,"name":"Jonathan Crane","created_at":"2018-04-11T13:39:52-06:00","sortable_name":"Crane, Jonathan","short_name":"Jonathan Crane","sis_user_id":"873392","integration_id":null,"login_id":"jcrane@goqwickly.com","enrollments":[{"id":40,"user_id":16,"course_id":9,"type":"StudentEnrollment","created_at":"2018-06-23T14:50:40Z","updated_at":"2019-02-04T17:05:41Z","associated_user_id":null,"start_at":null,"end_at":null,"course_section_id":8,"root_account_id":1,"limit_privileges_to_course_section":false,"enrollment_state":"active","role":"StudentEnrollment","role_id":3,"last_activity_at":"2020-04-07T16:41:09Z","last_attended_at":null,"total_activity_time":936,"grades":{"html_url":"https://qwickly.instructure.com/courses/9/grades/16","current_grade":null,"current_score":70.77,"fin..."}

 

However, when scopes are enforced and I am using the required scope mentioned in the documentation (url:GET|/api/v1/courses/:course_id/users), the response I receive does not include the enrollment information. Here is the response from the same request as stated above with developer key scopes enabled:

{"id":16,"name":"Jonathan Crane","created_at":"2018-04-11T13:39:52-06:00","sortable_name":"Crane, Jonathan","short_name":"Jonathan Crane","sis_user_id":"873392","integration_id":null,"login_id":"jcrane@goqwickly.com","email":"jcrane@goqwickly.com"}

I cannot see from the documentation that I am missing any additional scopes needed to request data from this endpoint, but I am not receiving any enrollment information. However, it does appear that I am missing some scope that would allow me to see the enrollment information.

Any help on this issue is greatly appreciated.

Labels (3)
0 Kudos
1 Reply
bhuggins
Surveyor II

Hiya @akshya , we recently ran across your message while encountering a similar issue with including term data along with courses.  Hopefully you've found the solution by this point, but in case not, the fix we found for our situation is there's a checkbox under the Enforce Scopes toggle that we had simply glossed over.

allowIncludeParams.png

Without that selected any "include[]" params are just ignored when calling the API.