cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Member

How to Get all users in API Communication Channel Request

Hello,

I'm new to APIs and have successfully been able to use a Get request to retrieve user information, but I want to be able to pull all users and not just a specific user as I have done so far.

We now require students to use their school emails in Canvas and made the change via automated SIS import this week. The problem is there seem to be some users where their school address came in as a secondary email instead of replacing the default(I assume due to them manually changing it in Canvas). My end goal is to find all users with a secondary email in Canvas so that those addresses can be removed.

My Question to you is now that I've successfully retrieved information for a specific user how do I pull all users in the Get request? I put an asterisk(*) where the user ID would go, but that did not work.

If needed, I'm using a code like below to retrieve Communication Channel Information

import requests
import json

url = 'https://<school>.instructure.com/api/v1/users/<user_id>/communication_channels'
headers = {'Authorization' : 'Bearer <token>'}


r = requests.get(url,headers = headers)

print(r.status_code)
print(r.text)
print(r.json())

Labels (1)
3 Replies
Highlighted
Learner II

I think the communication channel endpoint can only be used on an individual user.

So to do this for all users, you would need to use the Users API ( Users - Canvas LMS REST API Documentation ) to get the users and then call the channel API on each one.

Highlighted
Community Coach
Community Coach

Hi cljtech‌,

pklove‌ has provided you with the correct answer, can you please advise if this has fully resolved your original question?

Cheers,
Stuart

Highlighted
Instructure
Instructure

Peter is right that you need to loop through each user... Just one comment to hopefully save you some time.

If you already have the SIS user import file with the user_id and correct school email you can use the sis_user_id for the API call like this: 

url = 'https://<school>.instructure.com/api/v1/users/sis_user_id:<user_id>/communication_channels'

Saves you the trouble of writing a script pull the users.

Here's a community script (in Ruby) for updating users default email addresses. https://github.com/unsupported/canvas/tree/master/api/bulk_update_user_default_emails