joshkraemer
Community Member

Get a list of active only sections in a course

Hi- We're trying to pull a list of active sections for a course through the API. https://canvas.instructure.com/doc/api/sections.html#Section 

Canvas is returning all sections for the course, even the deleted ones. But the section object returned doesn't tell us if the section has been deleted. Is there a way to exclude the deleted sections?

The only way this seems possible is to rely on the Canvas data stream (https://community.canvaslms.com/t5/Admin-Guide/How-do-I-subscribe-to-Live-Events-using-Canvas-Data-S...) which tells us if a section was deleted. But then we have to maintain a list of all sections that were deleted for a course outside of Canvas every time we pull the list of sections.

0 Kudos
1 Reply
chriscas
Community Coach
Community Coach

Hi @joshkraemer,

I'm not able to reproduce this issue in my institution's Canvas instance.  If I run the sections API, it's only returning active sections, with no way to return deleted ones that I see.  I tried creating a new section, running the API to see it, then deleting that section, and re-running the API again and the section was indeed not returned for that last API call.

Is it possible that your API calls are getting cached or something?  I'm fairly certain that API has only ever returned active sections, so something seems very weird here.

-Chris

-Chris