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]
|
||||
$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
|
||||
$Request = @{
|
||||
Method = $Method
|
||||
@ -57,5 +58,6 @@ function Invoke-GraylogRequest {
|
||||
ContentType = $ContentType
|
||||
}
|
||||
if ($Body) { $Request.Body = $Body }
|
||||
Invoke-RestMethod @Request
|
||||
try { Invoke-RestMethod @Request }
|
||||
catch { throw $_.Exception.Message }
|
||||
}
|
Loading…
Reference in New Issue
Block a user