Sample code for 30+ languages & platforms
PowerShell

HTTP POST with Binary Data in Request Body

See more HTTP Examples

Do an HTTPS POST with a binary request body.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

$http = New-Object Chilkat.Http

$fac = New-Object Chilkat.FileAccess

$reqBody = $fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf")

$resp = New-Object Chilkat.HttpResponse
$success = $http.HttpBinary("POST","https://example.com/something",$reqBody,"application/pdf",$resp)
if ($success -eq $false) {
    $($http.LastErrorText)
    exit
}

$responseStatusCode = $resp.StatusCode
$("Status code: " + $responseStatusCode)

# For example, if the response is XML, JSON, HTML, etc.
$("response body:")
$($resp.BodyStr)