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
HTTP Methods
Query parameter
auth - String (required)
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”).
The response content is a 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.


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

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

Could anybody please provide input .