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

How to create a new course using the API

Our goal is to create a Google form with a few fields like "Course Name", to allow our teachers to create new Courses.  We will put a link to the Google Form in Canvas. The API says to use this:

/v1/accounts/{account_id}/courses 

My question is, what exactly is the account_id?  When I try and use the Live API located at https://ourdomain.com/doc/api/api-docs.json, the documentation states that the accound_id is an optional integer associated with the course.  How do I obtain this value for the user filling out the Google Form?

293422_pastedImage_6.png

Also, live API allows you to do a test run, but the account_id is REQUIRED.  So is this value required or optional? And if it's required, how do I get this value from the user who's filling out the Google Form and launching the API to create the course?

293486_pastedImage_7.png

Tags (2)
5 Replies
daniel_olivas
Community Participant

Also, in the API documentation for Creating a course.  It states that the account_id is the root account associated with the course.  Again, how do I get this value?

293487_pastedImage_1.png

Hi Daniel,

The ID that you're looking for depends on how you have your Canvas instance setup.  Your top level account is ID 1... If your institution uses sub-accounts like mine does you would need to go to that sub-account and up in the address bar you can see what ID is associated with that sub-account.  What I did was create a table on the back end that I then use to pull which sub-account to associate said course with.  

293457_pastedImage_1.png

For what you're looking for you might just provide the instructor a list of sub-accounts available and then on the back end of the google form have that associated with the ID of the account that you can put in when making the call. 

Hope this helps. 

Thanks Brian,

That helps.  Are you familiar with using Google Forms, and onFormSubmit?  We are using this to call the API and create the course.  Is there a way, during the onFormSubmit() to get the current user's info from Canvas?  In other words, how can I get the user's "id" from  Canvas during the onFormSubmit function?

Never mind.  This can be used:

GET /api/v1/users/self

Robbie_Grant
Community Coach
Community Coach

 @daniel_olivas ,

Were you able to find an answer to your question? I am going to go ahead and mark this question as answered because there hasn't been any more activity in a while so I assume that you have the information that you need. If you still have a question about this or if you have information that you would like to share with the community, by all means, please do come back and leave a comment.  Also, if this question has been answered by one of the previous replies, please feel free to mark that answer as correct.

 

Robbie