Find if user is root account admin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2017
03:30 PM
how can i find out if a user is AccountAdmin of the ROOT account via REST API? Meaning the master account of all the sub accounts?
Solved! Go to Solution.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2017
08:13 AM
Easily enough, all you need is the Admins API endpoint. This will list all admins for whichever account you need to query (in this case just add the root account ID).
GET /api/v1/accounts/:account_id/admins
You can also pass the user_id[] parameter to the query string if you want to see if the user in question exists as an admin under that account.
https://school.instructure.com/api/v1/accounts/self/admins?per_page=100
Edit: A PowerShell example to get AccountAdmins ONLY:
$res = invoke-restmethod "https://school.instructure.com/api/v1/accounts/self/admins?per_page=100" -method get -headers @{"Authorization" = "Bearer $auth"}
foreach ($r in $res) {
if ($r.role -like "AccountAdmin") {
$r
}
}