[ARCHIVED] Enforcing Scopes causing missing Data in Course Users' Enrollments call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.