chore: Ensure Graylog session is set before making requests, and added better error handling
This commit is contained in:
parent
4608f33c4a
commit
85c622f894
@ -49,6 +49,7 @@ function Invoke-GraylogRequest {
|
|||||||
[string]
|
[string]
|
||||||
$ContentType = "application/json"
|
$ContentType = "application/json"
|
||||||
)
|
)
|
||||||
|
if (-NOT (Test-GraylogSession -SkipSessionCheck)) { return } # Ensure that the Secrets are set
|
||||||
$Session = Get-Secret Graylog_Session -Vault Graylog -AsPlainText -ErrorAction Stop
|
$Session = Get-Secret Graylog_Session -Vault Graylog -AsPlainText -ErrorAction Stop
|
||||||
$Request = @{
|
$Request = @{
|
||||||
Method = $Method
|
Method = $Method
|
||||||
@ -57,5 +58,6 @@ function Invoke-GraylogRequest {
|
|||||||
ContentType = $ContentType
|
ContentType = $ContentType
|
||||||
}
|
}
|
||||||
if ($Body) { $Request.Body = $Body }
|
if ($Body) { $Request.Body = $Body }
|
||||||
Invoke-RestMethod @Request
|
try { Invoke-RestMethod @Request }
|
||||||
|
catch { throw $_.Exception.Message }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user