Updating sisid using python api

60 views
Skip to first unread message

Vaibhavi Deshpande

unread,
Mar 4, 2021, 12:13:46 PM3/4/21
to Canvas LMS Users
Hi,

I am able to see that the sisid is modified using the following code :-

login.sis_user_id = "S123456"


login

Out[44]: Login(_requester=<canvasapi.requester.Requester object at 0x0000018C6687F0C8>, id=184, user_id=186, account_id=1, unique_id=test...@gmail.com, created_at=2021-02-25T12:16:26Z, created_at_date=2021-02-25 12:16:26+00:00, sis_user_id=S123456, integration_id=None, authentication_provider_id=None)

But when i login to canvas portal, the sisid field is not updated. Kindly guide me how to update the sis_id of user in canvas table or using python api.




Eric Dannewitz

unread,
Mar 4, 2021, 11:54:40 PM3/4/21
to canvas-l...@googlegroups.com
If you use the CanvasAPI, it would be something like this. You'd have to find the current user, then edit them.

import sys
from canvasapi import Canvas

API_URL = "https://canvassite.instructure.com"
API_KEY = "YOURKEYHERE"

canvas = Canvas(API_URL, API_KEY)
account = canvas.get_account(1)
old_sis_login_id = sys.argv[1]
new_sis_login_id = sys.argv[2]
user = canvas.get_user(old_sis_login_id,'sis_login_id')
user.edit(
        user={
            'sis_user_id': new_sis_login_id
             {
        )

--

---
You received this message because you are subscribed to the Google Groups "Canvas LMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/canvas-lms-users/6b171155-0682-4017-b52f-24585d9c4ba5n%40googlegroups.com.


--
Eric Dannewitz 
Technology Assistant/District Tech
Google Cloud Certified Administrator & G Suite
Google Certified Educator Level 1 & 2
Acalanes Union High School District
District Office Technology Department
925-280-3980 x4309
edann...@auhsdschools.org

Vaibhavi Deshpande

unread,
Mar 5, 2021, 12:56:57 AM3/5/21
to Canvas LMS Users
I am getting the error while performing edit

raise Unauthorized(response.json())

Unauthorized: [{'message': 'user not authorised to perform that action'}]

Eric Dannewitz

unread,
Mar 5, 2021, 1:34:01 AM3/5/21
to canvas-l...@googlegroups.com
What I emailed was Python, not json. The Canvas API and Python errors don't look like that.

You need Python 3 to run this. And you need to install canvasapi (pip install canvasapi)

Then from powershell, you'd do 

python renamescript,py ssidold ssidnew



Reply all
Reply to author
Forward
0 new messages