2

I am trying to create a script to send a file with a body but somehow is just ends up giving me error code (400) bad request or (412)

so far this is what i have done

$fileBin = [System.IO.File]::ReadAllBytes("$PSScriptRoot\$filePath")

$data = @{
"Time"="$TimeNum"
"Axis1"="$ax1"
"Axis2"="$ax2"
"Point"="$point"
"Date"="$date"
"file"=$fileBin
}
$temp = Invoke-RestMethod -Uri $urisite -Method POST  -Body $data -ContentType 'multipart/form-data'

echo $temp

I've tried using inFile but that way I can't add in the contents. Is there any other way to do this?

Delita
  • 21
  • 2
  • http://stackoverflow.com/questions/22770213/using-powershell-invoke-restmethod-to-post-large-binary-multipart-form-data : maybe this would help ? – sodawillow Nov 17 '15 at 17:25
  • 1
    that one uses inFile. i need to post body content + file so inFile doesn't work for me – Delita Nov 18 '15 at 01:10

0 Answers0