cancel
Showing results for 
Search instead for 
Did you mean: 
rancho
Surveyor II

API to list all the courses in my institution

Jump to solution

I am brand new to Canvas.  I have never used it, but I have been asked to do some batch integrations with our other student system.  I have looked and found the correct API call for all the courses (/api/v1/accounts/:account_id/courses).  But I can not figure out what the account_id variable is in real life.  Is that my institutions id and if so where can I find that?   I am supposed to be an admin on our test site but I do not know exactly what I am looking for?  Any help appreciated.

Labels (1)
0 Kudos
1 Solution

Accepted Solutions
matthew_buckett
Adventurer II

For the root account (top of the sub-account hierarchy) you can use the special value of `self` which is documented on the IDs page (the top account normally has an ID of 1 but not always), so the URL would be `/api/v1/accounts/self/courses`. This API endpoint has paging enabled, so you will need to make multiple requests and page through the results. If you use the sub-account tool in an account you can browse to other accounts and the ID will end up in the URL.

However if you are wanting to process all courses in your Canvas deployment you are much better off running a Provisioning Report which is outlined in the standard canvas reports. There is an API to run reports if you want to automate it, or you can manually run these reports, download the file and the process it. Reports can also be run at a sub-account which allows you to process a subset of courses easily if you have a well designed sub-account hierarchy.

View solution in original post

0 Kudos
4 Replies
matthew_buckett
Adventurer II

For the root account (top of the sub-account hierarchy) you can use the special value of `self` which is documented on the IDs page (the top account normally has an ID of 1 but not always), so the URL would be `/api/v1/accounts/self/courses`. This API endpoint has paging enabled, so you will need to make multiple requests and page through the results. If you use the sub-account tool in an account you can browse to other accounts and the ID will end up in the URL.

However if you are wanting to process all courses in your Canvas deployment you are much better off running a Provisioning Report which is outlined in the standard canvas reports. There is an API to run reports if you want to automate it, or you can manually run these reports, download the file and the process it. Reports can also be run at a sub-account which allows you to process a subset of courses easily if you have a well designed sub-account hierarchy.

View solution in original post

0 Kudos

Hi Matthew

Thanks for the quick reply.   I tried both 1 and self in the request, but I am receiving a json message

"message""user not authorized to perform that action"
 
What do I have to tell my business user to do so I will have permission do you think? I am using a manually generated token that came from my account.
 
matthew_buckett
Adventurer II

There's some useful background on sub-accounts. Have you been added to an account? You should have access to an account as outlined in the admin account guide, if you don't see the admin icon then you need to ask one of your administrators to grant you access to the account you are supposed to be running reports against.

thanks I will do that.

Again thanks for the help and quick response.