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
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.