Canvas API: Enrolling students into course (query user ID/SIS ID)

Jump to solution
ac3680
Community Novice

I am using Canvas Free for Teachers. How can I enroll a student into my course programmatically using the Canvas API? I have the student's email address. The problem is that the student may or may not have a pre-existing Canvas account.

 

Assuming students do not have a Canvas Account, I (1) Create the user. This returns their ID, so I (2) Enroll the user. This works! However, some students already have a Canvas account, and Canvas API returns fail upon trying to create the user, and I cannot retrieve their ID and therefore am unable to enroll the user into my course.

 

> Is there a way to query a user's ID given their email address so I can enroll students? Or there may be a better approach to enrollment altogether. Alternatively, it seems this may be possible if I can query a user's SIS ID.

1 Solution
wurzel
Community Novice

Hi  Augustine,

In most cases where you would load a user by canvas id you can substitute in sis_user_id:<user_sis_id>. So it would look like this, if the user name is jsample:

/users/sis_user_id:jsample/profile

That gets you the user's profile which includes the canvas id. 

I'm unaware of any pure api way to do this with an email address. I do most of my lookups via sis_user_id.

View solution in original post