Via REST, how do I obtain a valid role_id list for a subaccount?

Jump to solution
memrys
Community Participant

In the documentation for the Admins REST API it encourages me to use role_id, but I can see no way to get a valid list of Admin roles and their IDs. Where in the API can I get the valid role_id list of Admin types for a specific subaccount?

The obvious choice, Roles, does not appear to be returning relevant data. Here is a screenshot from one of my subaccounts:

Screenshot 2022-04-19 090408.png

You can see the customized admins with special permissions; 'Herzing Staff' and 'Herzing - Faculty Demo.' You can also see the subaccount underlined in the URL at the top. However, using the roles API I am unable to query those roles for subaccount 224:

curl.exe -k "https://herzing.instructure.com/api/v1/accounts/224/roles" -X GET -H "Authorization: Bearer [...]" > result.json

The resulting JSON contains only six default roles, with none of our customized ones:

 

[
	{"id":1,"role":"AccountAdmin","label":"Account Admin",[...]},
	{"id":3,"role":"StudentEnrollment","label":"Student",[...]},
	{"id":4,"role":"TeacherEnrollment","label":"Teacher",[...]},
	{"id":5,"role":"TaEnrollment","label":"TA",[...]},
	{"id":6,"role":"DesignerEnrollment","label":"Designer",[...]},
	{"id":7,"role":"ObserverEnrollment","label":"Observer",[...]}
]

 

I thought that perhaps the roles were inherited. The parent of subaccount 224 is our root account, 1, but the root account does not have the Faculty Demo role (though it does have the Herzing Staff role). What am I doing incorrectly? How do I reliably query for these custom account roles?

Labels (2)
1 Solution

I figured it out -- you probably have more than 10 roles in that subaccount (there are some roles like Quizzes.NEXT service, SIS account roles for SIS imports, etc) -- 

query this URL and they should all pop up:

https://herzing.instructure.com/api/v1/accounts/224/roles?show_inherited=true&per_page=100

By the way, most API calls are paginated calls -- meaning it returns the first 10-20 results. If you add the per_page parameter to the call, you can get X number of results (I usually keep it at 100 then call the next page when needed).

Hope this helps!

View solution in original post