@@ -98,8 +98,7 @@ function Invoke-GHRestMethod
98
98
99
99
. NOTES
100
100
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.
103
102
#>
104
103
[CmdletBinding (SupportsShouldProcess )]
105
104
param (
@@ -144,10 +143,7 @@ function Invoke-GHRestMethod
144
143
145
144
# Telemetry-related
146
145
$stopwatch = New-Object - TypeName System.Diagnostics.Stopwatch
147
- $localTelemetryProperties = @ {
148
- ' UriFragment' = $UriFragment
149
- ' WaitForCompletion' = ($WaitForCompletion -eq $true )
150
- }
146
+ $localTelemetryProperties = @ {}
151
147
$TelemetryProperties.Keys | ForEach-Object { $localTelemetryProperties [$_ ] = $TelemetryProperties [$_ ] }
152
148
$errorBucket = $TelemetryExceptionBucket
153
149
if ([String ]::IsNullOrEmpty($errorBucket ))
@@ -193,12 +189,13 @@ function Invoke-GHRestMethod
193
189
$headers.Add (" Content-Type" , " application/json; charset=UTF-8" )
194
190
}
195
191
192
+ $NoStatus = Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus
193
+
196
194
try
197
195
{
198
196
Write-Log - Message $Description - Level Verbose
199
197
Write-Log - Message " Accessing [$Method ] $url [Timeout = $ ( Get-GitHubConfiguration - Name WebRequestTimeoutSec) )]" - Level Verbose
200
198
201
- $NoStatus = Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus
202
199
if ($NoStatus )
203
200
{
204
201
if ($PSCmdlet.ShouldProcess ($url , " Invoke-WebRequest" ))
@@ -292,7 +289,8 @@ function Invoke-GHRestMethod
292
289
Write-Log - Message " Unable to retrieve the raw HTTP Web Response:" - Exception $_ - Level Warning
293
290
}
294
291
295
- throw (ConvertTo-Json - InputObject $ex - Depth 20 )
292
+ $jsonConversionDepth = 20 # Seems like it should be more than sufficient
293
+ throw (ConvertTo-Json - InputObject $ex - Depth $jsonConversionDepth )
296
294
}
297
295
}
298
296
@@ -333,7 +331,7 @@ function Invoke-GHRestMethod
333
331
if (-not [String ]::IsNullOrEmpty($TelemetryEventName ))
334
332
{
335
333
$telemetryMetrics = @ { ' Duration' = $stopwatch.Elapsed.TotalSeconds }
336
- Set-TelemetryEvent - EventName $TelemetryEventName - Properties $localTelemetryProperties - Metrics $telemetryMetrics
334
+ Set-TelemetryEvent - EventName $TelemetryEventName - Properties $localTelemetryProperties - Metrics $telemetryMetrics - NoStatus: $NoStatus
337
335
}
338
336
339
337
$finalResult = $result.Content
@@ -461,14 +459,14 @@ function Invoke-GHRestMethod
461
459
{
462
460
# Will be thrown if $ex.Message isn't JSON content
463
461
Write-Log - Exception $_ - Level Error
464
- Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties
462
+ Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties - NoStatus: $NoStatus
465
463
throw
466
464
}
467
465
}
468
466
else
469
467
{
470
468
Write-Log - Exception $_ - Level Error
471
- Set-TelemetryException - Exception $_.Exception - ErrorBucket $errorBucket - Properties $localTelemetryProperties
469
+ Set-TelemetryException - Exception $_.Exception - ErrorBucket $errorBucket - Properties $localTelemetryProperties - NoStatus: $NoStatus
472
470
throw
473
471
}
474
472
@@ -531,7 +529,7 @@ function Invoke-GHRestMethod
531
529
532
530
$newLineOutput = ($output -join [Environment ]::NewLine)
533
531
Write-Log - Message $newLineOutput - Level Error
534
- Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties
532
+ Set-TelemetryException - Exception $ex - ErrorBucket $errorBucket - Properties $localTelemetryProperties - NoStatus: $NoStatus
535
533
throw $newLineOutput
536
534
}
537
535
}
0 commit comments