invoke-restmethod multipart content

Copper Contributor

I have a PowerShell script that calls the Canvas VLE SIS import API to batch enrol students into a course.  The script calls invoke-restmethod to post a multipart CSV file with the details of the students to enrol.  This is the format of the file:





Content-Disposition: form-data; name="attachment"; filename="enrol_S2020-A52172-D0016-1.csv"
Content-Type: text/csv; charset=utf-8






The content is uploaded and processed successfully when running on PowerShell 4.0.  However, if I run the same script in PowerShell 5.1, the content is uploaded but the processing fails.  I have verified that the CSV content is valid, so the only reason for this failure that I can think of is that PowerShell 5.1 handles multipart content different to 4.0.


Any suggestions on how I can change the script / multipart content so that the enrolment upload works on PowerShell 5.1 ?

0 Replies