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