RESTAPI - Multipart-formdata - image as binary

Hi ,

I am trying to upload image as binary data via REST API. I could not figured it out how this can done in powershell as the RESTAPI documentation is not much clear. I am getting invalid format error

RESTAPI documentation

Adds a file to extract to a newly created extraction job.
URL path
/files/order
HTTP Methods
POST
Query parameter
auth - String (required)
Body
The request content needs to be multipart/form-data. One part of the content needs to be the
Binary content (Part-Name = “orderFile”). The other part needs to be the metadata of type
OrderFileCreateData (Part-Name = “meta”).
Result
The response content is a OrderFileCreateData

OrderFileCreateData
fileName - String (required)
The name of the file
mediaType - String (required)
The the media type string of the content


WARNING: {“succeeded”:false,“errors”:[{“code”:“General_Job_Validation_InvalidOrderFile”,
“message”:“Provided order file is invalid!”,“messageParameter”:}]}
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.

Code

$FilePath = ‘C:\files\sample.tif’;
$fileBytes = Get-Content -Path $FilePath -Encoding Byte -raw
$boundary = [System.Guid]::NewGuid().ToString();
$LF = “rn”;
$body='{
“–$boundary”,
“fileName”:“sample.tif”,
“mediaType”: “application/octet-stream$LF”,
“orderFile”:“$($fileBytes)”
“–$boundary–$LF”

}'-join $LF
$result=Invoke-RestMethod -Uri $uri -Method $method -Headers $headers -Body $body

Could anybody please provide input .

Thanks,
Karthick