Hi ,
I’m tying to print Json response body with 400 bed request
Here is code:
try { if ($Responses = (Invoke-WebRequest @Param -ErrorAction Stop)){ $StatusCodes = $([int]$Responses.BaseResponse.statusCode)} Write-Host ("State code : " + $StatusCodes) }
>> catch [System.Net.WebException] { $StatusCodes = $_.Exception.Response.StatusCode.Value__ ; $Messages = (($_.Exception.response)) ; Write-Host ("State code : " + $StatusCodes) ; Write-Host ("Message: "+ $Messages) }
But i'm just getting status code 400 only, I want to have response body error as well like this
{
"status": "Failed",
"warnings": {
"errorCode": " ",
"errorDesc": " ",
"errors": [
]
}
}