How do we get the students emails when querying Canvas course sections through the API?

Jump to solution
Davidemolin
Community Explorer

Dear all, 

In my tool I need to query the course for sections, using the Canvas API (specifically, the endpoint /api/v1/courses/<course_id>/sections?include[]=students&include[]=total_students)

All seems to be fine and I get the expected result. Though I'm unsure about something:

The list of students returned by the call doesn't include an "email" field. Instead, I get a "login_id" field that is actually the student email...  Is this always the case? or is it possible to have a student with a "login_id" other than the email address? And if this is the case, how then can I get the email address of the student when querying the course sections? 

What I need here, in short, is a way to map the students returned by the Canvas API with the learners information provided by the LTI protocol when a launch request is issued and the student email seems to be the only information I can use to uniquely identtify the Canvas API student with the corresponding user provided by the LTI launch. 

So: is the login_id always representing the student email?

Thanks in advance!

Labels (1)
1 Solution
agschmid
Community Contributor

@Davidemolin try this call and see if it works for you:

/api/v1/courses/<course_id>/sections?include[]=students&include[]=email&per_page=100

View solution in original post