Get all students for current term

Jump to solution
rancho
Community Member

Hello

I am trying to get all the students for the current term.  I tried to run the SIS export for users, but that did not include their canvas ids.  So I thought I would use the api.  I get back the approximate number, but none of the students in a class are there.  Here is how I did it.  First I got the current term like so.

https://XXX.com/api/v1/accounts/self/terms/current

that returned 150 for the term number so I used that in the list the users call

https://XXX.com/api/v1/accounts/self/users?search_term=150&enrollment_type=student&per_page=200

And I had to page a while.  Like I said I got back 6500 students, but it does not seem like I am getting all of them.

Any ideas or suggestions appreciated.

cheers

bob

Labels (1)
0 Likes
1 Solution
matthew_buckett
Community Contributor

@rancho If you use the Provisioning Report, rather than the SIS Export then you will get the Canvas IDs of the users included in the export.

I don't think you can use the `search_term` parameter to search for users who just have enrolments in a term with an ID of 150. Looking at the documentation: https://canvas.instructure.com/doc/api/users.html#method.users.api_index it says about the search_term:



The partial name or full ID of the users to match and return in the results list. Must be at least 3 characters.

Note that the API will prefer matching on canonical user ID if the ID has a numeric form. It will only search against other fields if non-numeric in form, or if the numeric value doesn't yield any matches. Queries by administrative users will search on SIS ID, login ID, name, or email address


So I expect it's matching "150" in a different ID on the user and not in the term associated with the user's enrolments on courses.

 

View solution in original post

0 Likes