-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Milestone
Description
When running either Invoke-WebRequest
or Invoke-RestMethod
against a server returning an HTTP error code (e.g. 404), PowerShell 5 on Windows throws an exception which contains a response object. In PowerShell 6 on Mac OS X the response object is not available.
Steps to reproduce
Invoke-WebRequest http://httpbin.org/404
$Error[0].Exception.Response
Expected behavior
The expected behaviour is, that the exception contains a response as HttpWebResponse
object:
PS C:\> $Error[0].Exception.Response
IsMutuallyAuthenticated : False
Cookies : {}
Headers : {Connection, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Content-Length...}
SupportsHeaders : True
ContentLength : 233
ContentEncoding :
ContentType : text/html
CharacterSet : ISO-8859-1
Server : nginx
LastModified : 8/29/2016 12:47:17 AM
StatusCode : NotFound
StatusDescription : NOT FOUND
ProtocolVersion : 1.1
ResponseUri : http://httpbin.org/404
Method : GET
IsFromCache : False
Actual behavior
PS /> $Error[0].Exception.Response
PS />
Environment data
Name Value
---- -----
PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.9
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Jaykul
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues