cancel
Showing results for 
Search instead for 
Did you mean: 
binodpanta
Community Participant

Find a course across all subaccounts

Jump to solution

We are currently using the conclude option when we remove courses from our catalog now, and I am attempting to make a 'create_or_update' pattern so if we ever try to re-add a course to a catalog again, and transmit, we can change the course back from 'concluded' to 'offer' state (using the "course[event]" option here). Currently we simply fail the create operation, because we don't check if the course exists even if in deleted / concluded state... 😞

 
I am having trouble finding an api endpoint that can search for a course across all subaccounts regardless of the state it is in. Looks like I can only find under one account at a time. This means I have to loop over all subaccounts using this recursive option 
{{canvas_url}}/api/v1/accounts/1/sub_accounts?per_page=100&recursive=true
 
then loop over all subaccounts and accounts to find the course  using https://canvas.instructure.com/doc/api/accounts.html#method.accounts.courses_api
 
😞 hopefully there is an easier way? 
 
The reason I need to find under all subaccounts is that the course could have been added under a different subaccount or moved to a different subaccount and I would still need to be able to find it before I can decide if I need to create it or just update it.
 
 
Labels (1)
0 Kudos
1 Solution

Accepted Solutions
binodpanta
Community Participant

Thanks for your reply! 

 

I ended up looking up a root account using api, I can detect it because it has parent_account_id:null

then when I point my api to search courses for that account id instead, now I can find courses even under other subaccounts! 

this solves the problem for me

 

View solution in original post

4 Replies
binodpanta
Community Participant

we don't hold on to the course ids from canvas side in our system so we can't use any course specific apis to check if it exists. Hence we need to do a lookup,.. 😞 

JamesSekcienski
Community Participant

Have you considered downloading a course provisioning report from your root account and having your program search through CSV file to find the course?  Once found, the program could use the Canvas Course ID from the provisioning report to perform the actions you need.

I do hope to automate some of my programs more by not needing to get the provisioning report, but I have made some Python scripts that work well by using the information from course provisioning reports as the starting point.

binodpanta
Community Participant

Thanks for your reply! 

 

I ended up looking up a root account using api, I can detect it because it has parent_account_id:null

then when I point my api to search courses for that account id instead, now I can find courses even under other subaccounts! 

this solves the problem for me

 

View solution in original post

I'm glad to hear that performing an API call on the root account gets you all courses for sub-accounts too.  That will certainly make it easier when I refine my scripts to become more automated.