Skip to content

Commit 3c65460

Browse files
committed
capture response headers for rate limiting info
1 parent bcb820a commit 3c65460

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ function Invoke-ListGraphRequest {
124124

125125
try {
126126
$Results = Get-GraphRequestList @GraphRequestParams
127+
128+
if ($script:LastGraphResponseHeaders) {
129+
$Metadata.GraphHeaders = $script:LastGraphResponseHeaders
130+
}
131+
127132
if ($Results | Where-Object { $_.PSObject.Properties.Name -contains 'nextLink' }) {
128133
if (![string]::IsNullOrEmpty($Results.nextLink) -and $Request.Query.TenantFilter -ne 'AllTenants') {
129134
Write-Host "NextLink: $($Results.nextLink | Where-Object { $_ } | Select-Object -Last 1)"

Modules/CIPPCore/Public/GraphHelper/New-GraphGetRequest.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ function New-GraphGetRequest {
7373
Headers = $headers
7474
ContentType = 'application/json; charset=utf-8'
7575
}
76-
if ($IncludeResponseHeaders) {
77-
$GraphRequest.ResponseHeadersVariable = 'ResponseHeaders'
78-
}
7976

8077
if ($ReturnRawResponse) {
8178
$GraphRequest.SkipHttpErrorCheck = $true
8279
$Data = Invoke-WebRequest @GraphRequest
8380
} else {
81+
$GraphRequest.ResponseHeadersVariable = 'ResponseHeaders'
8482
$Data = (Invoke-RestMethod @GraphRequest)
83+
$script:LastGraphResponseHeaders = $ResponseHeaders
8584
}
8685

8786
# If we reach here, the request was successful

0 commit comments

Comments
 (0)