Sample code for 30+ languages & platforms
PowerShell

Example: Http.DownloadSb method

See more HTTP Examples

Demonstrates the DownloadSb method.

Chilkat PowerShell Downloads

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

$success = $false

$http = New-Object Chilkat.Http
$http.KeepResponseBody = $true

$sb = New-Object Chilkat.StringBuilder
$success = $http.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",$sb)

$statusCode = $http.LastStatus
if ($success -eq $false) {
    if ($statusCode -eq 0) {
        # Unable to either send the request or get the response.
        $($http.LastErrorText)
    }
    else {
        # We got a response, but the status code was not in the 200s
        $("Response status code: " + $statusCode)
        # Examine the response body.
        $("Response body:")
        $($http.LastResponseBody)
    }

    $("Download failed.")

}
else {
    $("Download success, response status = " + $statusCode)
    $($sb.GetAsString())
}