How do I undelete a Term using the API?

Jump to solution
PerryWay
Community Novice

While building the API client side interface for my employer I deleted a Term because I thought I'd be able to recreate it. Well, apparently Canvas keeps the term but it is no long accessible to be used or referenced in subsequent API calls. This wouldn't be a problem except that the SIS Term ID is already taken, so when I went to recreate a new term to replace it, I am presented with this response:

{

    "errors": {
        "sis_source_id": [
            {
                "attribute": "sis_source_id",
                "type": "SIS ID \"185\" is already in use",
                "message": "SIS ID \"185\" is already in use"
            }
        ]
    }
}
 
So the Term is already in use? But not really. It's deleted, as it shows here (workflow_state) when using the API to get the Term: 
 
{
    "id": 102,
    "name": null,
    "start_at": "2024-12-30T08:00:00Z",
    "end_at": "2025-01-31T23:59:59Z",
    "created_at": "2025-01-06T23:01:29Z",
    "workflow_state": "deleted",
    "grading_period_group_id": null,
    "sis_term_id": "185",
    "sis_import_id": null,
    "overrides": {},
    "course_count": 0
}
 
The thing is that SIS Term ID needs to be 185 to match our Term ID, so I'm in a bit of a pickle.
 
I was thinking from my vast experience with writing API server and clients and longevity in the Information Systems world authoring complete systems for various clients that when deleted that record is deleted. Not just made inaccessible. So my next question is, is there a way to clear the cache so to speak of deleted records? Am I stuck with this problem and won't be able to correct it ever? Alternatively can I undelete this term somehow? If there's an API method for undeleting I haven't found it. 
 
Thanks to anyone that can illuminate the path for me.
Labels (1)
0 Likes
2 Solutions

@PerryWay No worries! We all start somewhere 🙂

You'll want to go to your top-level account (root account), click on Settings, then click the Reports tab. One of the (many) choices there is the SIS Export.

Here are some more instructions on how to pull this report: https://community.canvaslms.com/t5/Admin-Guide/How-do-I-view-reports-for-an-account/ta-p/109

With the API, you can call the Start a Report endpoint.  This will allow you to pull the SIS Export report file as a CSV for processing in the programming language of your choice 🙂

I haven't tried this, but you may be able to call the Update Enrollment Term endpoint  to update the SIS ID even if the item is deleted.

View solution in original post

PerryWay
Community Novice
Author

Hi Melody, ahh I see, I'm not using the Root account, they made me an Admin account, so I don't see that menu option. I suppose that's only available for Root accounts. As for using the update term endpoint, I had tried that yesterday and got a response "The specified resource does not exist". However, I was finally able to fix the problem by creating a CSV terms.csv file and zip that and then import it and that indeed fixed the problem. Thank you so much for your willingness to help so quickly! 

By the end of next week I will be an expert! 🙂 I'm just bumbling around stubbing my toes at the moment!

Perry

 

View solution in original post