I have some code:
Try{ . . . . $webRequest = [System.Net.WebRequest]::Create(...)
$webRequest.Method = "GET" $webRequest.Accept = 'application/json;odata=verbose'
$webResponse = $webRequest.GetResponse() . . . . } Catch { $exceptionMessage = $_.Exception.Message $exceptionItem = $_.Exception.ItemName "$exceptionMessage" }
The output that I am getting is:
Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (500) Internal Server Error."
The problem is that I want to first get more detail and second avoid the exception by checking the status code of the response. But if part of the error is the GetResponse is called with 0 arguments I don't know how to check this error code. I have used this same code to get a response from other URLs but this one eludes me and I am not sure how to proceed.
Thank you.
Kevin
Kevin Burton