From fa6e319f226f54c98bf036fcb2692649337be2a0 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Mon, 15 Apr 2024 12:54:38 +0200 Subject: [PATCH] Connection: Fix Headers with Powershell 7.4.2 where need to set Content-Type With PS 7.4.2, need to configure Content-Type to Application/json (or text-json) Fix: #246 --- PowerFGT/Public/Connection.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerFGT/Public/Connection.ps1 b/PowerFGT/Public/Connection.ps1 index 0ef2cedb..6f5f0fae 100644 --- a/PowerFGT/Public/Connection.ps1 +++ b/PowerFGT/Public/Connection.ps1 @@ -182,9 +182,9 @@ function Connect-FGT { $url = "https://${Server}:${port}/" } - $headers = @{} + $headers = @{ "content-type" = "application/json" } if ($ApiToken) { - $headers = @{ "Authorization" = "Bearer $ApiToken" } + $headers += @{ "Authorization" = "Bearer $ApiToken" } } else { #If there is a password (and a user), create a credentials @@ -261,7 +261,7 @@ function Connect-FGT { #Remove extra "quote" $cookie_csrf = $cookie_csrf -replace '["]', '' #Add csrf cookie to header (X-CSRFTOKEN) - $headers = @{"X-CSRFTOKEN" = $cookie_csrf } + $headers += @{"X-CSRFTOKEN" = $cookie_csrf } $uri = $url + "logindisclaimer" if ($iwrResponse.Content -match '/logindisclaimer') {