Enroll trust users with SIS ID via API

Jump to solution
Brandon_Brown
Community Explorer

Hello, We are looking for a way to enroll trust users via the API, using their sis_user_id (instead of Canvas user ID).

https://community.canvaslms.com/t5/Canvas-Admin-Blog/Trust-Account-User-Roles-and-Expectations/ba-p...

On the page above it states: "Trusts do not provide any automation for trust enrollments. Users are enrolled via CSV uploads or via the API." This seems to imply that it's possible to do, but there is no documentation on how to achieve it here: https://canvas.instructure.com/doc/api/enrollments.html. The missing piece seems to be passing the 'root_account' parameter that references the trusted/root account of the user. This is what enables trust enrollments to be processed via SIS upload using SIS ID. We've tried a few iterations of calls and none have worked for us yet.

Is there anyone who can confirm if this is possible and what the correct parameters are, if so? Here is an example call of what we're looking to do:

curl https://extendunh.test.instructure.com/api/v1/courses/618/enrollments \

-X POST \
-H 'Authorization: Bearer ABC123' \ (anonymized the token)
-F 'enrollment[user_id]=sis_user_id:923552219' \
-F 'enrollment[root_account]=unh.test.instructure.com' \
-F 'enrollment[type]=StudentEnrollment' \
-F 'enrollment[enrollment_state]=active' \
-F 'enrollment[course_section_id]=551' \
-F 'enrollment[notify]=false'

{"errors":[{"message":"The specified resource does not exist."}]}%

If we make the same call with a local (non-trust) user, omitting the [root account] parameter, the enrollment is processed successfully. If there is anyone out there that has accomplished trust enrollments via the API, we would be very appreciative to know how it was accomplished. If it's not possible, we will likely need to query to find the Canvas user id and enroll with that. 

Thanks in advance!

Brandon

Brandon Brown
Applications Administrator
Enterprise Technology & Services
University System of New Hampshire
Brandon.brown@unh.edu

0 Likes
1 Solution
robotcars
Community Champion

@Brandon_Brown 

Have you tried the root account value without 'test'? Just use the production domain, even on test/beta.

edit:

While I recommend always using the production domain, even in test, this doesn't seem to be the cause of your troubles.

----

The api specifically uses root_account_id, not root_account, which will be in BIGINT. The easiest way I can suggest finding this is likely the link in the Admin Tray to the Root Account, while you're in the secondary instance dashboard. The link should contain the longid. Otherwise from the root account, open the Dev tools, and see ENV.DOMAIN_ROOT_ACCOUNT_ID.

Additionally. I was unable to use the sis_user_id helper in the enrollment[user_id] param, it only took my global id, and then root_account_id became unnecessary. Not sure root_account_id if passed is even used.

I'm submitting a ticket as this affects us (obviously and others) and the endpoint should utilize the helper and root account.

So the request will not work without the global id of the user.

If you want to enroll until this is fixed CSV Import will work if you use their SIS_ID and the Root_Account name.

 

View solution in original post