diff --git a/ARAH/ARAH.psd1 b/ARAH/ARAH.psd1 index b39a802..1d881f2 100644 --- a/ARAH/ARAH.psd1 +++ b/ARAH/ARAH.psd1 @@ -3,7 +3,7 @@ RootModule = 'ARAH.psm1' # Version number of this module. - ModuleVersion = '1.3.7' + ModuleVersion = '1.3.8' # ID used to uniquely identify this module GUID = '5bf61bed-a3da-4550-949a-a869b8dc29c6' diff --git a/ARAH/changelog.md b/ARAH/changelog.md index 6dfdb6e..74d234d 100644 --- a/ARAH/changelog.md +++ b/ARAH/changelog.md @@ -1,4 +1,7 @@ # Changelog +## 1.3.8 (2023-09-08) + - If the result is JSON you can enable converting it to a HashTable with the `Invoke-ARAHRequest -ConvertJsonAsHashtable` switch. This is needed in case of the error `Cannot convert the JSON string because it contains keys with different casing. Please use the -AsHashTable switch instead.` + - File Downloads can be handled ## 1.3.6 (2023-03-03) - If using a HashTable object for the `Invoke-ARAHRequest -Body` parameter it is only converted to json if the content type matches `json`. ## 1.3.5 (2023-01-18) diff --git a/ARAH/functions/Invoke-ARAHRequest.ps1 b/ARAH/functions/Invoke-ARAHRequest.ps1 index 9844315..b08320e 100644 --- a/ARAH/functions/Invoke-ARAHRequest.ps1 +++ b/ARAH/functions/Invoke-ARAHRequest.ps1 @@ -58,6 +58,9 @@ .PARAMETER PagingHandler Name of a registered PSFScriptBlock which should process the automatic paging of data. + .PARAMETER ConvertJsonAsHashtable + If set the json result will be converted as a HashTable + .EXAMPLE $result = Invoke-ARAH -connection $this -path "/v4/auth/login" -method POST -body @{login = $credentials.UserName; password = $credentials.GetNetworkCredential().Password; language = "1"; authType = "sql" } -hideparameters $true @@ -81,12 +84,14 @@ $Body, [Hashtable] $URLParameter, [string]$InFile, + [string]$OutFile, [string]$ContentType, [bool]$EnableException = $true, [ValidateSet('CertificateCheck', 'HttpErrorCheck', 'HeaderValidation')] [String[]]$SkipCheck = @(), [string]$RequestModifier, [string]$PagingHandler, + [switch]$ConvertJsonAsHashtable, [switch]$EnablePaging ) $uri = $connection.webServiceRoot + $path @@ -138,6 +143,9 @@ If ($InFile) { $restAPIParameter.InFile = $InFile } + If ($OutFile) { + $restAPIParameter.OutFile = $OutFile + } try { If ($RequestModifier) { @@ -146,6 +154,7 @@ } Write-ARAHCallMessage $restAPIParameter $response = Invoke-WebRequest @restAPIParameter + if($OutFile){return} if ($PSBoundParameters.Debug) { $global:invokeARAHrestAPIParameter = $restAPIParameter Write-PSFMessage "Saving restAPIParameter to `$global:invokeARAHrestAPIParameter" -level Debug @@ -164,7 +173,11 @@ $result = $connection.Charset.GetString([System.Text.Encoding]::GetEncoding(28591).getBytes($result)) } if ($effectiveContentType -like '*json*') { - $result = $result | ConvertFrom-Json + if ($ConvertJsonAsHashtable){ + $result = $result | ConvertFrom-Json -AsHashtable + }else{ + $result = $result | ConvertFrom-Json + } } Write-PSFMessage "Response-Header: $($response.Headers|Format-Table|Out-String)" -Level Debug Write-PSFMessage -Level Debug "result= $($result| ConvertTo-Json -WarningAction SilentlyContinue -Depth 5)"