Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
memrys
Community Member

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

Jump to solution

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?

1 Solution

Accepted Solutions

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

4 Replies
melodyc_lam
Community Member

Have you tried adding the parameter show_inherited to the query?

So it would look like:

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

 

I hadn't known about or noticed that parameter, so thank you very much! It certainly resolves the issue of having to query the parent. However...

[
	{"id":1,"role":"AccountAdmin",[...]
	{"id":3,"role":"StudentEnrollment",[...]
	{"id":4,"role":"TeacherEnrollment",[...]
	{"id":5,"role":"TaEnrollment",[...]
	{"id":6,"role":"DesignerEnrollment",[...]
	{"id":7,"role":"ObserverEnrollment",[...]
	{"id":11,"role":"Help Desk",[...]
	{"id":12,"role":"Herzing Staff",[...]
	{"id":14,"role":"Quizzes.Next Service",[...]
	{"id":15,"role":"LTI Account",[...]
]

This does not resolve the issue that I am presented with options in the UI for this subaccount that do not show up via the REST API.

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!

memrys
Community Member

That's annoying; most APIs I have used indicate when they are paginated, with a result count or page number attribute or similar. But thank you very much @melodyc_lam, I'd still be beating my head against a wall if it weren't for you. 😁