AnsweredAssumed Answered

Find all Public Courses using API

Question asked by ysmalls Champion on Mar 22, 2019
Latest reply on May 15, 2019 by Brian Bisbee



My disclaimer:  I’m not a programmer but wanting to learn.

David Willmore  had posted created a post regarding course’s that were set to Public visibility and needed update them to private and I’m at a point where I need this done.


I started by running the Public Courses report by Term for this school year only.


Thanks the response from James Jones  I was able to create API calls using Postman but some data is quirky.

I first ran the Public Courses report by Term.


I created a Get API that list all my public courses( again thanks James Jones):


GET /api/v1/search/all_courses?public_only=1&per_page=100


However, my results only list 47 courses and I know there are more since I was cross-referencing them again the report I had generated but I moved on to the next API call.


I then created a PUT API to update the course to private (again thanks James Jones ):


PUT /api/v1/courses/:course_id?course[is_public]=0


Now when I run this for just one course it does work but funny thing is that this will then select “Customize” and set the Syllabus to “Public”?  Weird right or am I missing something?


Therefore, to eliminate that issue I change the API call to:


PUT /api/v1/courses/:course_id?course[is_public]=0&course[public_syllabus]=0


Finally, I got what I wanted and was able to update one course to private and keep the syllabus as private.


So I wanted to be able to update all courses through API call using Postman but realized that’s not possible?  Well it is kind of but I would need to create something to iterate or a collection that will run one course at a time?  Again this is using Postman and way above my head and I’m really liking API’s!


I am getting help from one of our programmers Brian Bisbee and we are working on a PowerShell script but have noticed that the search API does not appear to be returning the results from all courses, but rather just the ones that public in the index. We were able to get all of the course by running GET /api/v1/accounts/1/courses?per_page=100. It doesn’t seem like we are able to filter on that through the API call for is_public so we are downloading all of the courses and working through them with a powershell script to get just the public ones. Is there a better way to get this info through the API?

We also use the Canvas Data API which in the courses table does include which of our courses are publicly visible, but that only updates once a day, so we are trying to find a more “on-demand” method that is faster. 

We have the powershell script set up to iterate through all of the records and flip them to private, but just wanting to find a faster way to get the courses that are public