functions/private/Get-ErrorFromResponse.ps1
function Get-ErrorFromResponse { param ( [Parameter(Mandatory = $true)] $response ) $result = $response.GetResponseStream() $reader = New-Object System.IO.StreamReader($result) $reader.BaseStream.Position = 0 $reader.DiscardBufferedData() $responseBody = $reader.ReadToEnd(); return $responseBody } |