(PowerShell) HTTP POST with Binary Data in Request Body
Do an HTTPS POST with a binary request body. Note: This example requires Chilkat v11.0.0 or greater.
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)
|