Canvas API Sortable Student Name Format Change

Jump to solution
JoshuaBunzel
Community Member

I have code that fetches a list of students in the course using the following endpoint:

CANVASURL:443/api/v1/courses/COURSEID/users?enrollment_type[]=student&enrollment_state[]=active&per_page=100
 
Previously I would receive student data that looks like this:
 
{ id: '12345', name: 'John Doe', created_at: '2020-08-07T12:34:24-07:00', sortable_name: 'Doe, John', short_name: 'John Doe', sis_user_id: 'STU_7479905', integration_id: null, login_id: 'johndoe@johnny.org', email: 'johndoe@johnny.org' }
 
Suddenly, without changing anything, I am getting the same data except the sortable_name does not have a comma in it. Which is massively throwing things off with the application I have setup.
 
Any idea why this is suddenly happening? I can't imagine that Canvas would suddenly change the API to have it return sortable names without commas
Labels (2)
0 Likes
1 Solution
JenMurphyA
Community Team
Community Team

Hi @josh ,

You are correct that sortable_name normally returns last name and first name with a comma in between. Could your data have changed? You might want to try last_name and first_name, just to see if those are giving what you'd expect. According to the Canvas API Documentation, sortable_name should return the name of the user that is normally used for sorting groups of users, such as in a gradebook.
"sortable_name": "Doe, John", Another idea is to log into Canvas as an Admin and verify a user's "Sortable Name" in the UI, which displays on the user's profile page. 

View solution in original post