@@ -200,6 +200,10 @@ function Invoke-GHRestMethod
200200 $bodyAsBytes = [System.Text.Encoding ]::UTF8.GetBytes($Body )
201201 $params.Add (" Body" , $bodyAsBytes )
202202 Write-Log - Message " Request includes a body." - Level Verbose
203+ if ($LogRequestBody )
204+ {
205+ Write-Log - Message (ConvertTo-Json - InputObject $Body - Depth 20 ) - Level Verbose
206+ }
203207 }
204208
205209 [Net.ServicePointManager ]::SecurityProtocol= [Net.SecurityProtocolType ]::Tls12
@@ -217,7 +221,7 @@ function Invoke-GHRestMethod
217221 if ($PSCmdlet.ShouldProcess ($jobName , " Start-Job" ))
218222 {
219223 [scriptblock ]$scriptBlock = {
220- param ($Url , $Method , $Headers , $Body , $ValidBodyContainingRequestMethods , $TimeoutSec , $ScriptRootPath )
224+ param ($Url , $Method , $Headers , $Body , $ValidBodyContainingRequestMethods , $TimeoutSec , $LogRequestBody , $ ScriptRootPath )
221225
222226 # We need to "dot invoke" Helpers.ps1 and GitHubConfiguration.ps1 within
223227 # the context of this script block since we're running in a different
@@ -239,6 +243,10 @@ function Invoke-GHRestMethod
239243 $bodyAsBytes = [System.Text.Encoding ]::UTF8.GetBytes($Body )
240244 $params.Add (" Body" , $bodyAsBytes )
241245 Write-Log - Message " Request includes a body." - Level Verbose
246+ if (Get-GitHubConfiguration - Name LogRequestBody)
247+ {
248+ Write-Log - Message (ConvertTo-Json - InputObject $Body - Depth 20 ) - Level Verbose
249+ }
242250 }
243251
244252 try
@@ -272,7 +280,7 @@ function Invoke-GHRestMethod
272280 }
273281 }
274282
275- $null = Start-Job - Name $jobName - ScriptBlock $scriptBlock - Arg @ ($url , $Method , $headers , $Body , $ValidBodyContainingRequestMethods , (Get-GitHubConfiguration - Name WebRequestTimeoutSec), $PSScriptRoot )
283+ $null = Start-Job - Name $jobName - ScriptBlock $scriptBlock - Arg @ ($url , $Method , $headers , $Body , $ValidBodyContainingRequestMethods , (Get-GitHubConfiguration - Name WebRequestTimeoutSec), ( Get-GitHubConfiguration - Name LogRequestBody) , $PSScriptRoot )
276284
277285 if ($PSCmdlet.ShouldProcess ($jobName , " Wait-JobWithAnimation" ))
278286 {
0 commit comments