@@ -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 ))
@@ -198,13 +194,14 @@ function Invoke-GHRestMethod
198
194
return
199
195
}
200
196
197
+ $NoStatus = Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus
198
+
201
199
try
202
200
{
203
201
Write-Log - Message $Description - Level Verbose
204
202
Write-Log - Message " Accessing [$Method ] $url [Timeout = $ ( Get-GitHubConfiguration - Name WebRequestTimeoutSec) )]" - Level Verbose
205
203
206
204
$result = $null
207
- $NoStatus = Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus
208
205
if ($NoStatus )
209
206
{
210
207
$params = @ {}
@@ -293,7 +290,8 @@ function Invoke-GHRestMethod
293
290
Write-Log - Message " Unable to retrieve the raw HTTP Web Response:" - Exception $_ - Level Warning
294
291
}
295
292
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 )
297
295
}
298
296
}
299
297
@@ -326,7 +324,7 @@ function Invoke-GHRestMethod
326
324
if (-not [String ]::IsNullOrEmpty($TelemetryEventName ))
327
325
{
328
326
$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
330
328
}
331
329
332
330
$finalResult = $result.Content
@@ -454,14 +452,14 @@ function Invoke-GHRestMethod
454
452
{
455
453
# Will be thrown if $ex.Message isn't JSON content
456
454
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
458
456
throw
459
457
}
460
458
}
461
459
else
462
460
{
463
461
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
465
463
throw
466
464
}
467
465
@@ -524,7 +522,7 @@ function Invoke-GHRestMethod
524
522
525
523
$newLineOutput = ($output -join [Environment ]::NewLine)
526
524
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
528
526
throw $newLineOutput
529
527
}
530
528
}
0 commit comments