The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
I have some programming experience in VBA and Access SQL and was hoping to join your developers forum to get tips on where to start programming the building blocks in Canvas. For instance Blackboard uses JAVA whereas I gather, from the limited video clips I have seen, Canvas uses JSON. I am looking to take things from inception to the API integration stage. If anyone could offer some advice and guidance as to where I should start, would be much appreciated.
Thanks.
Solved! Go to Solution.
PS I:\> $csv = import-csv -Delimiter "," -Path ‘L:\Teaching and Learning\Learning Resources\eLearning\Canvas\Rollover\1819\RolloverFiles\Mapping2017-18\Final\ShellsMap\Map2017-2018_ManualCourse.csv’
foreach ($line in $csv){
$token = "Token"
$headers =@ {"Authorization"="Bearer "+$token}
$url = "https://institution.beta.instructure.com:443/api/v1/courses/"+ $line.destination_id +"/content_migrations"
$Body = @{"migration_type"="course_copy_importer";"settings[source_course_id]"=$line.source_id}
Invoke-RestMethod -Method Post -Headers $headers -Uri $url -Body $Body
}
Canvas doesn't like the Token it seems even after regenerating it.
At line:7 char:11
+ $headers =@ {"Authorization"="Bearer "+$token}
+ ~
Unrecognized token in source text.
At line:7 char:14
+ $headers =@ {"Authorization"="Bearer "+$token}
+ ~~~~~~~~~~~~~~~
The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a
variable or a property.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnrecognizedToken
For (1), you should be POSTing to:
https://institution.test.instructure.com/api/v1/courses/:course_id/course_copy
The POST isn't part of the URL, its the http method (like GET, PUT, PATCH, DELETE).
Hi Peter, thanks for this.
I created three test 2018 course shells (one in the example below: 2018-Brickwork) by SIS import.
I note from Garth's addition that parameter source_course, but I don't see anywhere in the documentation where this is or where it is applied.
I attempted the following combinations however, based on some supposition and guidance from yourself and Garth. Again I received a Page not found response:
https://myinstitution.test.instructure.com/api/v1/courses/:2017-Brickwork/course_copy
Thinking it will need the new course in there, I tried this.
https://myinstitution.instructure.com/api/v1/courses/:2017-Brickwork/:2018-Brickwork/course_copy
I note from the video API Calls Made Simple by Curtis Rose, that a Token is required that is placed within the Call. The video says the token can be acquired through Account Settings under "Approved Integrations". The nearest label I could find resembling this is something called "Trusted HTTP Referers".
Furthermore there is no mention of the Access Token requirement within the Call documentation.
What am I doing wrong?
Confused!
David, @de_millington
I just started using PowerShell to make API calls within Canvas, and I was confused at first. Here’s a couple of things that made it easier for me to understand how the process works. When first starting out with the API, this Canvas API guide was very helpful. I would use your institution’s Live API to build the URL. https://<Your_Institutuion>.beta.instructure.com/doc/api/live After changing this link to match your institution, it should show the live API area. The Canvas guide above talks about using the Live API as well.
You can get the access token by following this guide: https://community.canvaslms.com/docs/DOC-10806-4214724194
Before running any API calls on production, make sure you test them on the Beta and Test instances. I would also make sure you know what every line of code does before running it.
This is how a very basic API GET call within PowerShell 5.1 looks:
$token = "Your token here"
# the headers area stays the same
$headers =@{"Authorization"="Bearer "+$token}
$url = "Your URL within this field"
Invoke-RestMethod -Method Get -Headers $headers -Uri $urlI would also read about the GET, POST, and PUT API calls. GET gathers information of some kind while POST and PUT make changes. When I first started, I made several GET calls to learn how the process worked before trying to make any changes to the Beta instance.
@de_millington all API calls are documented, Copy course content can be found here
I have copied a specific section of that documentation below, and highlighted "source_course" as bold text.
It's the first parameter defined under the "Parameter" column below.
You can also search this page for source_course to find the definition.
If you are going to work with the API, I strongly recommend getting comfortable with the documentation available from Canvas.
Start here: The Basics and scroll down all of the options in the left panel to explore the API and get comfortable with how it is organized.
I hope this helps.
url:POST|/api/v1/courses/:course_id/course_copyDEPRECATED: Please use the Content Migrations API
Copies content from one course into another. The default is to copy all course content. You can control specific types to copy by using either the 'except' option or the 'only' option.
The response is the same as the course copy status endpoint
| Parameter | Type | Description | |
|---|---|---|---|
| source_course | string | ID or SIS-ID of the course to copy the content from | |
| except[] | string | A list of the course content types to exclude, all areas not listed will be copied. Allowed values: | |
| only[] | string | A list of the course content types to copy, all areas not listed will not be copied. Allowed values: |
Hi David,
The REST APIs simply involve sending/receiving data over https --- so you can use any programming language you want.
A good resource to read when you are starting out with the API is: https://community.canvaslms.com/docs/DOC-14390-canvas-apis-getting-started-the-practical-ins-and-out...
Peter
Thanks for this Peter. Please see my reply to Garth. Any further pointers with respect to that reply would be appreciated
Dave.
As promised, one year later, here's a couple of video guides that may help anyone just getting started, like me in 2018, with the process of bulk Canvas course content copying, rolling one year's academic course content to the next.
The first video is all about preparation, which seems to me to be about 80-90% of the job.
The second video is all about the API Call to automate the copy process.
While the second stage looks the simplest part of the work flow, the effort and knowledge required to get to that stage is neither underestimated nor undervalued. On the contrary, it took a lot of research and communication with the community here, help lent unselfishly by those members who I would like to acknowledge, especially Samuel Morris. Credits, therefore, are posted in the second video, without whose help I may have still been labouring away at individually copying courses through the UI.
Guide to preparing for the Canvas course rollover
Guide to performing the API call to rollover bulk course content
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.