Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
Hello all!
As part of standard procedure, I am trying to bulk/mass delete courses in our API instance that are 2 years or more older. I have tried using the impost csv method but as you know, this does not work with courses that have no SIS ID. This leaves us with several courses (hundreds) that need to be deleted one by one, even with the Canvas API Live instance.
Now, I am trying to do this using Postman. I have tested the token and a GET request successfully but am running into issues when I use the DELETE request.
Does anyone have instructions or tips to get this done in Postman?
Hi @MARTHADELAPAZ,
I have very limited experience with Postman (really just used it during my Canvas Certified Technical Admin courses). From my recollection, Postman has a limit to the number of calls you could do per month for the free version, and I think this would go over that. If you're open to using something other than Postman, I do this exact thing (along with a lot of other tasks) in a Python script that we run daily. It basically goes term by term, looking for any with a term that's more than 7 years old (our retention policy, that would be 2 for you), then lists all courses for the matching term and deletes them. I may be able to pare down my code and send it to you if you were interested.
Let me know!
-Chris
That would be amazing! I am very interested. Thank you so much, Chriscas.
Hi @MARTHADELAPAZ,
I'll be at InstructureCon this week, so I probably won't get over to this until next week if that's okay. Are you also interested in having advance notice emails sent to the teachers of the courses warning of their upcoming removal?
-Chris
I am very interested in this! I have put in several requests in the Canvas Support Panel for help and their responses have not been helpful for me at all..... I have 2 years worth of courses I am trying to delete and I cannot get them deleted.
That would be great. How much time before you delete do the messages get sent out?
Hi @MARTHADELAPAZ,
We send notices 60, 30, and 5 days before deletion, but that's easily configurable in my python script. For that functionality to work, you'll need to have an SMPT mail server available to send through.
If I can get stable enough WiFi to VPN into my work machine from InstructureCon, I may be able to get to this sooner, but I'd expect next week at this point (I'm currently on a plane, and WiFi works good enough to post here, but definitely not good enough for a VPN)
-Chris
Hello @chriscas,
I have a few weeks to complete this, so there's no rush. Enjoy InstructureCon and we can connect after you return. I will be returning to the office on the 17th.
@chriscas I am interested in this as well! I, too, am at InstructureCon and would love to connect!
@MARTHADELAPAZ When I want to delete a long list of courses, I create a text file containing the numerical IDs of all the courses to delete, then run this script in Terminal.
#!/bin/bash
# This script is really simple. Edit the variables to set the server,
# log file name, and feed file name (add paths as needed).
# The feed file should just be plain text with numerical course IDs on
# separate lines.
# API token is assumed to be in environment variable canvasAPItoken.
# Successful delete response is just {"delete":true}
# For that reason logging numerical course ID and time makes log useful.
# VARIABLES - Adjust values and save file as.
canvas_domain="canvas.instructure.com"
log_file="course_deletion_log.txt"
feed_file="course_deletion_feed.txt"
# Loop through lines in feed file. Append to log file.
while read course_canvas_id
do
echo "$course_canvas_id"
response=$(curl -s -S "https://$canvas_domain/api/v1/courses/$course_canvas_id" -X DELETE -H "Authorization: Bearer $canvasAPItoken" -F "event=delete")
echo "$(date +'%H:%M:%S') $course_canvas_id $response" >> $log_file
done < $feed_file
Hi @MARTHADELAPAZ, @CynthiaEdwards1, and @WhitneyBaker,
I was finally able to get a version of my script that I was happy enough with to post to the public. Please see the Retention Policy (Course Deletion) Script blog post I just created for information on my script. It may work great for some of you or perhaps need modifications to fir your needs, but I hope it at least gives all of you a place to start from.
-Chris
To participate in the Instructure Community, you need to sign up or log in:
Sign In