From 0913fc206975627d4d02658ea6ff3114bf60b620 Mon Sep 17 00:00:00 2001 From: Arnike Date: Sat, 17 Dec 2022 01:11:05 +0300 Subject: [PATCH] content-type fix --- functions/private/Invoke-Request.ps1 | 16 +++++++--------- functions/public/New-Session.ps1 | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/functions/private/Invoke-Request.ps1 b/functions/private/Invoke-Request.ps1 index 7925d41..a8c9764 100644 --- a/functions/private/Invoke-Request.ps1 +++ b/functions/private/Invoke-Request.ps1 @@ -27,22 +27,20 @@ function Invoke-Request { if ($_tokenStatus -eq "Expired") { Update-Session } $_uri = "$($script:psipamSession.URL)/api/$($script:psipamSession.AppID)/$Controller" - if ($SubController -ne $null) { $_uri += "/$SubController" } - if ($Identifiers -ne $null) { $_uri += "/$($Identifiers -join '/')/" } + if ($null -ne $SubController) { $_uri += "/$SubController" } + if ($null -ne $Identifiers) { $_uri += "/$($Identifiers -join '/')/" } - $_headers = @{ - "Accept" = "application/json" - "Content-Type" = "application/json" - } + $_headers = @{ } switch ($script:psipamSession.AuthType) { "Credentials" { $_headers.Add("token", $script:psipamSession.Token) } "Token" { $_headers.Add("phpipam-token", $script:psipamSession.Token) } } $_arguments = @{ - Method = $Method - Uri = $_uri - Headers = $_headers + Method = $Method + Uri = $_uri + Headers = $_headers + ContentType = "application/json" } if ($Method -eq "POST" -or $Method -eq "PATCH") { diff --git a/functions/public/New-Session.ps1 b/functions/public/New-Session.ps1 index 0c3d068..8a105b1 100644 --- a/functions/public/New-Session.ps1 +++ b/functions/public/New-Session.ps1 @@ -107,5 +107,6 @@ function New-Session { break } } + return $script:psipamSession } Export-ModuleMember -Function New-Session \ No newline at end of file