How to programatically restrict blueprint items?

Jump to solution
bro16111
Community Novice

I have about a hundred blueprint courses where I want to restrict specific items in the course. There is this API call to set restrictions on a blueprint course object. However I can't find the content_id for the item I want to restrict. There is a Show module item call which in theory returns a ModuleItem with its content_id. However when I use the Show module item call (with include[]=content_details) it only return information such as the following.

 

{
"id": 5616,
"title": "My Title",
"position": 2,
"indent": 1,
"type": "Page",
"module_id": 1524,
"html_url": "https://example.instructure.com/courses/154/modules/items/5616",
"page_url": "my-title",
"url": "https:/example.instructure.com/api/v1/courses/154/pages/my-title",
"published": false

"content_details": {
"locked_for_user": false
}
}

 

I have been able to manually go to the course and inspect the element I want to restrict and grab that content_id and the call works, but that defeats the whole purpose.  Am I missing something or is there something wrong with the API?

0 Likes
1 Solution
bro16111
Community Novice
Author

I was able to figure out how to do it. The items I was trying to restrict were pages, but per the documentation a ModuleItem only returns a content_id for the types 'File', 'Discussion', 'Assignment', 'Quiz', and 'ExternalTool'. So I had to use the pages api. The problem is, is that the Modules api return what the groups and subgroup are for each Module but the pages doesn't. So I had to request both. I got the modules and their subgroups and I got the pages. I then cross-listed the pages information with the modules information. In that way I was able to get the correct items I wanted to restrict.

View solution in original post