Skip to content

Commit

Permalink
Connection: Fix Headers with Powershell 7.4.2 where need to set Conte…
Browse files Browse the repository at this point in the history
…nt-Type

With PS 7.4.2, need to configure Content-Type to Application/json (or text-json)

Fix: #246
  • Loading branch information
alagoutte committed May 12, 2024
1 parent 2d267bb commit fa6e319
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions PowerFGT/Public/Connection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit fa6e319

Please sign in to comment.