I'm trying to simplify the upload of Packages using the API but can't seem to get it to work.
I'm trying to code this in Powershell and a snippet of this code is below:
$MCFQDN = "SERVER.LOCATION"
Get-MobiControlToken
$response = ""
$APIURL = "https://$MCFQDN/MobiControl/api/packages"
$filename = "c:\Temp\PackageName.pcg"
$Header = @{}
$Header["Authorization"] = "Bearer " + $Token
$Header["Accept"] = "application/json"
try {
$response = Invoke-RestMethod -Uri $APIURL -ContentType "multipart/related;" -Method POST -InFile $filename -Headers $Header
$response
}
catch {
$($_.Exception.Message)
}
The Get-MobiControl function works without issue, but each time I run this script I get a 415 error stating "Unsupported media type provided. Expected media type is multipart/related" but I have defined that. I've also tried defining it in the header instead. Is there something glaringly obvious I'm missing?
Thanks in advance.
