@@ -98,8 +98,7 @@ function Invoke-GHRestMethod
9898
9999 . NOTES
100100 This wraps Invoke-WebRequest as opposed to Invoke-RestMethod because we want access to the headers
101- that are returned in the response (specifically 'MS-ClientRequestId') for logging purposes, and
102- Invoke-RestMethod drops those headers.
101+ that are returned in the response, and Invoke-RestMethod drops those headers.
103102#>
104103 [CmdletBinding (SupportsShouldProcess )]
105104 param (
@@ -144,10 +143,7 @@ function Invoke-GHRestMethod
144143
145144 # Telemetry-related
146145 $stopwatch = New-Object - TypeName System.Diagnostics.Stopwatch
147- $localTelemetryProperties = @ {
148- ' UriFragment' = $UriFragment
149- ' WaitForCompletion' = ($WaitForCompletion -eq $true )
150- }
146+ $localTelemetryProperties = @ {}
151147 $TelemetryProperties.Keys | ForEach-Object { $localTelemetryProperties [$_ ] = $TelemetryProperties [$_ ] }
152148 $errorBucket = $TelemetryExceptionBucket
153149 if ([String ]::IsNullOrEmpty($errorBucket ))
@@ -198,13 +194,14 @@ function Invoke-GHRestMethod
198194 return
199195 }
200196
197+ $NoStatus = Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus
198+
201199 try
202200 {
203201 Write-Log - Message $Description - Level Verbose
204202 Write-Log - Message " Accessing [$Method ] $url [Timeout = $ ( Get-GitHubConfiguration - Name WebRequestTimeoutSec) )]" - Level Verbose
205203
206204 $result = $null
207- $NoStatus = Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus
208205 if ($NoStatus )
209206 {
210207 $params = @ {}
@@ -293,7 +290,8 @@ function Invoke-GHRestMethod
293290 Write-Log - Message " Unable to retrieve the raw HTTP Web Response:" - Exception $_ - Level Warning
294291 }
295292
296- throw (ConvertTo-Json - InputObject $ex - Depth 20 )
293+ $jsonConversionDepth = 20 # Seems like it should be more than sufficient
294+ throw (ConvertTo-Json - InputObject $ex - Depth $jsonConversionDepth )
297295 }
298296 }
299297
@@ -326,7 +324,7 @@ function Invoke-GHRestMethod
326324 if (-not [String ]::IsNullOrEmpty($TelemetryEventName ))
327325 {
328326 $telemetryMetrics = @ { ' Duration' = $stopwatch.Elapsed.TotalSeconds }
329- Set-TelemetryEvent - EventName $TelemetryEventName - Properties $localTelemetryProperties - Metrics $telemetryMetrics
327+ Set-TelemetryEvent - EventName $TelemetryEventName - Properties $localTelemetryProperties - Metrics $telemetryMetrics - NoStatus: $NoStatus
330328 }
331329
332330 $finalResult = $result.Content
@@ -454,14 +452,14 @@ function Invoke-GHRestMethod
454452 {
455453 # Will be thrown if $ex.Message isn't JSON content
456454 Write-Log - Exception $_ - Level Error
457- Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties
455+ Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties - NoStatus: $NoStatus
458456 throw
459457 }
460458 }
461459 else
462460 {
463461 Write-Log - Exception $_ - Level Error
464- Set-TelemetryException - Exception $_.Exception - ErrorBucket $errorBucket - Properties $localTelemetryProperties
462+ Set-TelemetryException - Exception $_.Exception - ErrorBucket $errorBucket - Properties $localTelemetryProperties - NoStatus: $NoStatus
465463 throw
466464 }
467465
@@ -524,7 +522,7 @@ function Invoke-GHRestMethod
524522
525523 $newLineOutput = ($output -join [Environment ]::NewLine)
526524 Write-Log - Message $newLineOutput - Level Error
527- Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties
525+ Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties - NoStatus: $NoStatus
528526 throw $newLineOutput
529527 }
530528}
0 commit comments