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.
@de_millington I recently posted on how to implement the Canvas API using .NET that might help:
I have created a workflow engine to automate admin tasks and reporting using the API, Canvas has been very easy to work with in my opinion. The source code I shared is the base of many tools that I've created for our institution. I hope it is useful for you.
Some other things I've posted on regarding use of the API:
Once you establish your base library you are off to the races.
Thanks for this Garth.
Garth has provided some excellent resources/information, but I'm also going to share this with the Canvas Developers group in the Community. They are the ones who do the back end programming and stuff like this and are an excellent resource! I would also strongly encourage that you join the group so you have access to their resources!
Thanks for taking the time to put this together. Much appreciated Garth, I'll look forward to going through this, though it looks like I've got a steep learning curve without any knowledge of C#.
If you're coding scripts for PowerShell, it might be easier than you think.
Let me know if you have questions, I'm happy to answer.
Take a moment to learn the basic REST methods. As stated by others, it is relatively easy once you get the basic construct of it and understand the authentication the API uses.
Perhaps this may be useful to you: Download data to Excel using VBA and the API (workbook with code attached)
We are giving the Canvas Admins area a little bit of love (especially questions that are really, really old) and just want to check in with you. This will also bring this question new attention.
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
Hi Robbie,
Thanks for extending the 'love' and so sorry to respond late to this. I probably made this request a year too early, as it took me that time to get to grips with the basic functionality of Canvas. Now that I am a year further on with Canvas, I am in a better place to begin considering the possibilities of a more development role. I am very pleased to say that one of the ideas I put forward for development (New Gradebook - aka Gradebook smart views) is now in Beta. I have spotted a couple of bugs, but the first impressions are that it is beginning to look like the finished article.
Looking forward, I need to get some experience developing APIs for a variety of uses, plus anything else that might prove useful, perhaps some JavaScript for example. My coding experiencing amounts to VB and that is not directly useful for Canvas. Ultimately, I would like to move our analytics towards more automation. Unless I have missed any vital functionality, it would appear that Canvas does not permit the pull down of cross-course grades, across the institution. These have to be done individually, which makes the task for gathering data extremely onerous.
If anyone else has some pointers as to how they have tacked this in their instruction, that would be gratefully received.
Kind Regards,
Dave
Hi Garth /community,
Have just skimmed some research on PowerShell; that it was developed by Microsoft for purposes of task automation and configuration management. Much beyond this I haven't a clue. With respect to Rest APIs, JSON, and PowerShell I feel I need to really start on the bottom rung with this, not only in terms of getting to grips with how they should be used, but how they work together. And so...a couple of things to run by you and the community of programmers...
How do the following applications fit into the broad scheme of things in terms of start/finish for implementing automation of Canvas processes:
Would I be correct in assuming that PowerShell is the platform/language used to develop the process, and that the Rest APIs are what is required to get that code into Canvas?
I have been given some generic code for 2 objectives, but I need to understand how to apply it to our particular needs and circumstances. I need to know how to implement it once it has been developed and tested.
Many thanks.
@de_millington without details of your requirements, it's really hard to say what path you should take.
To answer your question:
"Would I be correct in assuming that PowerShell is the platform/language used to develop the process, and that the Rest APIs are what is required to get that code into Canvas?"
PowerShell is one tool you could use to make API calls to Canvas to send and receive data.
JavaScript is also a tool you could use to make API calls to Canvas to send and receive data.
API allows you to exchange data with Canvas, but will not allow you to push "code" into Canvas.
It will be up to you to leverage the Canvas API to make the calls necessary to satisfy whatever requirement you are working on. Your code will run either in your browser, or on your servers. Even if you build an LTI application, at the end of the day that LTI application will be hosted and run on your servers, LTI applications do not run as part of Canvas or on Canvas servers, Canvas simply exposes your LTI application as an iFrame on the page but it is hosted and running on your servers.
I hope that helps.
Thanks for this Garth. I have marked this as helpful as it genuinely gets me off the blocks, but it would be even more helpful to break down some of the jargon. 'Leverage' for instance, sounds like an asset stripping term applicable of the banks during the financial crisis of '08. I'm assuming, perhaps, you mean in this context 'to make the most of'.
When you say your code will run inside the browser, I know you are not referring to days when I developed VBA for Access databases, since that was all done on computer drives. I'm thinking of HTML in an HTML editor package. Permit me to make the case even more basic. Canvas possesses Rich Content Editors that toggle between HTML view and Preview, but where would this be interfaced in Canvas?
I was planning on getting to grips with JavaScript as it seems the next logical step of learning after HTML, plus Canvas uses JSON. After having read the API getting started guide however, The simplicity of Python compared to JavaScript has convinced me to pursue that code as an API scripter. But I'm still not seeing in practice how this is done in Canvas. Is there any documentation you can point to that shows a project being built from start to finish, rather than snippets here and there that don't join the dots?
Lastly, in lieu of your comments about the purpose of the API being to serve Canvas as a universal tool, versus the LTi being for our own institution, I surmise I am planning to build the latter rather than the former.
With respect to the details of what I hope to achieve:
Any further pointers would be much appreciated.
Thanks.
@de_millington it sounds as though you need to develop an LTI toolkit to handle your custom needs.
There is quilte a bit of information out there on LTI.
I made these three posts on how to get your application to appear in Canvas:
.NET LTI Project - Part 1 - Connect to Canvas
.NET LTI Project - Part 2 - Launch Request
.NET LTI Project - Part 3 - OAuth
Then followed up with these posts covering how to handle OAuth to keep track of the user once they are in your environment:
.NET - OAuth2 Workflow: Part 1 - Authrorize Redirect
.NET - OAuth2 Workflow: Part 2 - Access Token & State
.NET - OAuth2 Workflow: Part 3 - Refresh Token
Each set of posts has source code associated with it.
I hope you will update here with your status and let us know how your project is going.
Thanks for this info Garth, I will take a look at this soon. An update to address the first of my 3 project aims:
Create a tab ( a link within the global navigation panel within our Canvas site, to a bespoke area for placement of global announcements. This would avoid cluttering the learner Dashboard with global announcements, but give much higher profile attention than course level announcements afford ).
This has been addressed in the community https://community.canvaslms.com/thread/13627-help-with-custom-menu-icons-and-script . I tinkered with the code provided by Canvas and managed to embed an additional icon menu icon linked to a bespoke learning space.
Secondly, with regard to the third point : Automate the process of course rollover...(with respect to copying old course content to new course shells). This was something that Instructure did gratis for us last year, but because we signed up to a lower level service agreement, they will not be providing the same this year. It turns out however, our Information Services department use PowerShell and they will have a go at addressing this. This has brought my thinking back to getting to grips with PowerShell and its application with APIs rather than LTIs. I would be interested in any further thoughts you might have on this.
@de_millington the API will give you the tools you need to copy course content.
You certainly don't need an LTI to copy course content.
Take a look at the Copy course content API call.
Have you thought through how you will keep track of this?
There are likely multiple faculty teaching a subject, each with their own style.
You might consider building a database to keep track of things:
- a table to catalog course templates for each course/instructor combination
- a table to keep track of the courses as they come through your SIS import
-- during SIS import you would need to keep track of the first time you are seeing a cousre, look up the instructor associated with that instance of the course and find their template in your database.
- a table to schedule the course copy and keep track of succes / failure / retry
So you may end up having two workflows:
1. Your SIS import to gather and log your courses + associated instructors + schedule the course content copy
2. A workflow to watch for new course copy records, look up the associated template based on course type and instructor, and initiate the content copy as well as monitor and repot on the status.
You could do this with .NET, JavaScript, PowerShell...any tool you choose that is capable of making the API calls and accessing your database.
I hope that helps.
Garth Egbert so using the example in the link you provided, to copy course content:
As the literature states "For migrations that don't require a file to be uploaded, like course copy..." there are 2 workflows:
1. POST to create
2. Us Progress specified in progress_url
We have 2 statements for the POST:
POST /api/v1/courses/:course_id/course_copy
Scope: url:POST|/api/v1/courses/:course_id/course_copy
Plus taking the url from Appendix A resource list would we add the POST to our test site like this:
https://institution.test.instructure.com/POST|/api/v1/courses/:course_id/course_copy
When I do this, it brings up a Google page with search results on API testing.
My question is 2 fold:
What url should I be posting for our institution instead of the above?Second, is course_id a generic default term to copy all new courses or am I suppose to list all specific course ids in the new course shell structure?What URL are you using to access your instance of Canvas? In other words, what URL are you putting in the browser to get to your instance of Canvas? Use that same URL to make your API calls.
:course_id represents the course you are copying into, and the parameter source_course represents the course you are copying from.. You will need to make API calls for each individual course.
Word of caution, test in Beta or Test before you make calls against your production instance.
OK I'm a little further on thanks to you Garth and Samuel (please don't turn off the drip feeds :smileyblush: !).
So you can see the latest fruits of my labours in the added screen shots.
OK so I generated the token twice, once in the live area, once in the Beta. I copy/pasted those tokens to the beta site (top image) :https://<Your_Institutuion>.beta.instructure.com/doc/api/live and then applied course_id, source_course_id, and migration type (assumed to be copy_course_importer, as this is only one that seems to chime with the manual course copies we perform through the UI). Finally I selected Try it Out! Like I said I got an error response 404 on both attempts).
Question1: How does Canvas know which API applies to which token? Is it related to the law of corresponding actions: i.e. save a token and the next API that is tried in the sequence engages with that token?
Question2: Is this site https://<Your_Institutuion>.beta.instructure.com/doc/api/live with all its embedded REST APIs with Try it Out! buttons a simulation or a real-time (be that Beta or live site) POST?
Question 3: Given what I have presented, can someone please account for the error?
Thanks in advance.
@de_millington I have never tried to test the API calls using the reference you have given.
The tool I use is Postman, take a look at this post: API Testing: Postman
Let me know if that helps.
Hi Garth, This is helpful. I have managed to download the app and have begun looking at some tutorials on YouTube.
As you can see from my response to Jaap, his advice paid off in terms of getting the Canvas API to work with my institution. The downside is that this API generator works for one course copy at a time. While I have requested further incites to leveraging this feature on multiple courses, I have my doubts this can be pursued further since there is nothing indicative of this in the literature.
Having some sort of spreadsheet with course codes and source codes seems to me to be the minimum mandatory requirements, but how would this fit into an API? Are there any resources that you can point me to that indicate how to leverage a Postman API to work for multiple courses?
Hi @de_millington , API calls are usually not used as a single command or action, most of the time it will be multiple Get call, maybe also Put, Post or Delete calls to get done what you need. The Live API you experimented with is meant for exploring the API possibilities and sometimes to just quickly perform some changes using data from reports from Canvas, but it was never intended as a full production tool (at least how I interpreted it). To understand what the API can offer you and to know what you need to prepare and process the data, take a look at https://community.canvaslms.com/docs/DOC-14390-canvas-apis-getting-started-the-practical-ins-and-out...
Hopefully that is helpful to you.
OK thanks Jaap, we seem to be going back to start now with APIs. I have read about half in detail and glanced through all of Canvas APIs: Getting started, the practical ins and outs, gotchas, tips, and tricks and cannot find any helpful pointers on how to apply scripts in APIs for multiple courses. I will however, press on with any general resources I can find. If you do in the meantime come across specifics I'm interested in, I would be grateful if you can place any links in this space.
Thanks again for all your contributions..
@de_millington you can use Postman to string together multiple API calls, but that is not the road I would go. Postman is not a software development tool, personally I don't find it well suited for running full algorithms / business logic.
I would continue to pursue the use of PowerShell if that's what you know, doing a quick search just here in the community I found this: How to POST in powershell You can likely find more relevant resources with your own search.
JavaScript is also a good option, and also returns good search results. @James did a nice post on a use case for JavaScript here: Sorting Rubrics Made Easy
Thanks for your regular contributions and I apologise for pressing you relentlessly, mostly on a daily basis ( I'd also give you a virtual cigar or glass of your favourite brew for your patience). The use of PowerShell is not what I know, but what our IS department are quite familiar with. They, however, have lost 2 of their most experienced staff, one swapping the education arena for the high-paying commercial security industry, while the other is on indeterminate compassionate leave. I had intended to teach myself all this and accomplish the course rollover process before set deadlines, but I think I was too ambitious within the time frames I'd set myself.
The challenges I see with the programming guides in the Canvas Community is they provide glimpses into the process, with no clear examples connecting the dots, from start to finish. Our institution will have to cough up the dollars for Canvas and let them do it this time. At least (I hope) by this time next year I will be in a state to do this myself. Thanks again!
I think you need to use the canvas course id's, not the sis id's...
Thankyou Jaap Stelstra . I'd offer you a virtual cigar or glass of champagne if there was one.
After doing some cartwheels through the office in my excitement, it only then occurred to me that this feature works for one course at a time. What then does one do with 600 plus courses? It seems to me that this technique is more laborious than doing a manual course copy, since the Token will also have to be generated 600 plus times.
I'm wondering if anything can be done with the response body or header code (body code shown below)?
Request url:
https://myinstitution.beta.instructure.com:443/api/v1/courses/3228/content_migrations
Response Body:
{
"id": 6753,
"user_id": 59,
"workflow_state": "running",
"started_at": "2018-08-09T15:25:44Z",
"finished_at": null,
"migration_type": "course_copy_importer",
"created_at": "2018-08-09T15:25:44Z",
"migration_issues_url": "https://myinstitution.beta.instructure.com/api/v1/courses/3228/content_migrations/6753/migration_iss...",
"migration_issues_count": 0,
"settings": { "source_course_id": 77, "source_course_name": "Workforce Development", "source_course_html_url": "https://myinstitution.beta.instructure.com/courses/77" },
"progress_url": "https://myinstitution.beta.instructure.com/api/v1/progress/30456",
"migration_type_title": "Course copy" }
You would want to use a programming language to loop through a list of course ids and make an API call at each loop. Maybe something like this PowerShell script.
$csv = import-csv -Delimiter "," -Path 'C:\temp\example.csv'
foreach ($line in $csv){
$token = "your token here"
$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
}I would be very careful running a script like this and make sure you know what each line does. Also make sure you are working within the beta server instance since API scripts can cause vast changes to a system. Definitely use cation with it.
This is how your CSV file should look with the Source_id and Destination_id headers:
########CSV Example############
##Source_id,destination_id
##1000,2000
##3000,4000
# The numbers in the above example csv file are course ids.
# The Source_id column in the csv file is for courses that have the content that you want copied into the new courses.
Thanks Sam, this is possibly the most concise and at the same time fullest examples yet of how to pursue this code-wise. I am familiar with the looping concept from my self taught VBA experiences, but will have to tackle this in PowerShell to see how it should really be applied. May well get back to this space to pick your brains some more. I just wonder how this compares with the brevity of Python? Besides the need to get to grips with PS, I was rather sold on the idea of Python when I discovered how concise it's coding was compared to JavaScript.
I don’t have a programming background, so PowerShell was easier to learn for me than Python or JavaScript. PowerShell scripts seem to be easier to break apart and find out what each command does. When I looked at Python, at least for me, I had a hard time getting over the new to programming aspect of the language vs PowerShell’s more scripting language than programming where you can run each command at a prompt.
This is a little bit off topic, but one of the things that I like about PowerShell is that they add new CmdLets and parameters to old CmdLets with each new version of PowerShell. For example with PowerShell Core version 6, they added a parameter that handles Pagination for you in the “Invoke-RestMethod” command. When you make an API Get call against Canvas, they limit you to 10 or 100 results per call with a link to the next call that contains the next 10 or 100 results. As an example, if you were making a call to gather all the courses in a specific term and there were more than 100 results you would need to handle the Pagination next rel links to get courses 101 to 200 and so on. This was making writing a script more complex, but with the “-FollowRelLink” parameter in PS Core 6, it handles all of that process for you. I had spent several days trying to figure out how to use Pagination before I found out that the newer PS version could do it automatically with a parameter.
This is what the command looks like in PS Core 6 that handles Pagination:
Invoke-RestMethod -Method Get -Header $headers -Uri $URL -FollowRelLink -MaximumFollowRelLink 20
A couple of questions if you please Samuel Morris.
I presume single # is to comment out the code, but what does ## do?
The source_id and destination_id as written in your example:
##1000,2000
##3000,4000
If I was to tabulate this, would I be correct in assuming this schematically corresponds as follows:
source_id | destination_id |
1000 | 2000 |
3000 | 4000 |
So presumably one would input these codes, line by line, small to large in a csv file. Assuming PS will stop execution when it reaches the last line, why then would a loop be required as you intimated previously?
The two ## are just comment signs I had in my PS script. I forgot to take them out when I was adding it to the reply. The looping part is done within the “foreach” command. The $line variable with either the .destination_id or .source_id part is what tells the loop what course id to grab. Once a line in the CSV file becomes null, from no object or string, it will end the loop from my understanding. The loop will cause the code to run the API Post for every course id in the CSV file. For each course copy, you need a separate API call which the "foreach" command handles. The PS “foreach” command loops through the content contained within the { } brackets.
You can get a list of course IDs from running either a provisioning report or using an API Get call against the accounts API. One of the fields will contain the course id. Here's the API call.
GET /api/v1/accounts/:account_id/courses The way you have the table formatted is correct. From my understanding, the course IDs don't have to be organized sequentially since each "foreach" loop is considered a separate API call.
OK Samuel, I had a go at running this for the first time in PS based on your code. I have clearly run into some parsing issues, plus I'm not sure where you get the number 443 in your code on line number 6.
Also I may have made the same mistake as when I was attempting to parse the one course copy tester, where I used course id rather than the page number that you pointed out (correction Jaap pointed out) corresponds with the course home page.
I generated the token within the beta environment, but Canvas is having a problem with it ( see response in red) and also a comment about a closing bracket not being there.
Any ideas what's going wrong?
Thanks.
PS Microsoft.PowerShell.Core\FileSystem::\\thfs1\TNL_MC00515> $csv = import-csv -Delimiter "," -Path ‘L:\Teaching and Learning\Learning Resources\eLearning\Canvas\Rollover\1819\RolloverFiles\Mapping2017-18\Final\Shells\Map\Map2017-2018_ManualCourse.csv’
foreach ($line in $csv){
$token = "Token here"
$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
At line:4 char:11
+ $headers =@ {"Authorization"="Bearer "+$token}
+ ~
Unrecognized token in source text.
At line:2 char:24
+ foreach ($line in $csv){
+ ~
Missing closing '}' in statement block or type definition.
At line:4 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
You will need to change the $url variable to match your Canvas instance. The Institution part of the url is just an example of how it should look. The 443 is the HTTPS port number of the url. You can get your url link from the Live API course copy area.
I would also edit your last post to remove the token you included, so no one can see it who views your post.
Hi Samuel,
Thanks for taking the timeout to respond. First let me say I did apply the real moniker of our Institution to the part of the url (I redacted it here for privacy reasons). This leaves me to query about the token.
During the testing last week, I applied a token generated within the live site to a beta site API. It didn't work until I generated a token from within the Beta site. Secondly, once I had used that token, and though it didn't lead to a successful parse, I found that I had to regenerate the token again for the next instance where I had used the correct code. Maybe this was coincidence, but I note from the error response that this parse is saying...
+ FullyQualifiedErrorId : UnrecognizedToken
Are you saying tokens can still be used again and again within different environments?
Another thing about the 443, which appears in the request url I made on last weeks test.
When I plug this as follows into my address bar and search
https://institution.beta.instructure.com:443/api/v1/courses
It redirects to a different page https://institution.beta.instructure.com/api/v1/courses
with code that fills the entire page. Is this supposed to be like that?
When I test out the API, I log into the Beta instance and generate a Beta token. In the Token generator box, I set the expiration date to be a week ahead in time. From my understanding, the Beta instance resets every week and the Test instance every three weeks. So a new token will need to be generated every week for the Beta environment. From this Canvas post, it's recommended to not use a Production token within a script that you are testing on the Test or Beta environments because of the possibility of something getting accidentally run on Production that's meant for Beta.
In our Beta environment, we can reuse a Beta token within the Beta as long as the token hasn't expired or the Beta instance hasn't reset.
When I generated the url from the Live API for the script, it had the 443 port in the link. The 443 part may be taken out when it redirects since the first part of the url contains https. 443 is the port number for HTTPS, so it may be redundant? I'm not sure.
The code that is generated on the page is most likely the JSON data. This data is what you would get from an API get call. When the PS script runs the API course copy call, it shouldn't necessarily show the JSON data, but it would probably show it if you went to the url.
JSON data is extremely useful when making API Get call. As an example, if you made an API call to gather a list of courses, the results would come back as JSON data. When using the PS command "Invoke-RestMethod", PS automatically converts the JSON data to PS Objects though. If you use the "Invoke-WebRequest" PS command, it does not convert the JSON data.
Thanks, as ever, Samuel , for your explanation - it pretty much makes perfect sense. I'll do further research on the differences between the Invoke-REST and WEB actions and their applications, though for other starters following this thread, it might be useful if you imparted some of your wisdom.
I pretty much followed your advice and script to the letter and yet it still threw an error (as noted in this thread 14 Aug, 09:56).
Is there anything else that might be a miss?
Post Script (as opposed to Power Shell) - I tried to be clever and copy the link location to the thread on 14 Aug, 09:56, but it seems to redirect to the top of the page. Perhaps a Canvas boffin can advise how to link to specific points in the thread timeline?
I tested this version of the script and it worked without errors. It uses the "Invoke-WebRequest" CmdLet instead of "Invoke-RestMethod" The error may have come from the "Invoke-RestMethod" command. In the past I had only used the "Invoke-WebRequest" command, so when I found RestMethod, I converted my scripts to it since it automatically converts JSON data to PS Objects. That could be why it's getting an error?
$csv = import-csv -Delimiter "," -Path 'C:\temp\example.csv'
foreach ($line in $csv){
$token = "token here"
$headers =@{"Authorization"="Bearer "+$token}
$url = "https://example.beta.instructure.com/api/v1/courses/"+ $line.destination_id +"/content_migrations"
$Body = @{"migration_type"="course_copy_importer";"settings[source_course_id]"=$line.source_id}
Invoke-WebRequest -Method Post -Headers $headers -Uri $url -Body $Body
}
After saving the script in PowerShell ISE as a ps1 script, I opened a PS terminal and used the "cd" command to go to the directory where the script was saved. Then I started typing the first letters of the name of the script and pressed the Tab keyboard key. That put up the script like this
.\example.ps1 I then hit enter and ran the script. It then gave an http 200 response for each API call signifying that it was successful. The courses that were listed in the CSV file had content copied.
Superb! Amazing! We have lift-off! Voila! Wow! Uncork the Champagne! Butta-bing-butta-bong! Ureka! Now I've run out of superlatives!
In fact I didn't strike gold at first, I got a string of error messages about line 7 character1. It seemed to point to errors with the file headers. When I looked again at my data file, I could see that I was making the same mistake as last week. i.e. I was using course_id (essentially same as section_id or short course name in the UI). To confuse matters, Provisioning reports list course_id (used in your API) as "canvas_course_id". So, canvas_course_ids must be used in the data file, but I guess it doesn't matter what you call the headers, as long as the API refers back to them.
I plan to make a screencast of how I did the whole thing after we get through our most busy time of the year, but essentially, folks can follow the thread and see how a relative novice went from zero to lift-off in under 3 weeks. Your advice was pivotal!
The script should work after you swap the "institution" part in the $url variable to match your college. The url link should follow your college's Canvas direct link. For example, "your_college.beta.instructure.com" The rest of the url has the variables in it that feed the course ids into the API call at each line of the csv file.
$url = "https://institution.beta.instructure.com:443/api/v1/courses/"+ $line.destination_id +"/content_migrations"The script below also has the closing bracket added, so it shouldn't have that error.
$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 here"
$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
}
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.