Qlik-Cli-Windows
Qlik-Cli-Windows copied to clipboard
Update-QlikProxy returning 400 Bad Request
I'm trying to link a new virtual proxy to the default proxy for my central node using the "-virtualProxies" field of Update-QlikProxy, but I keep getting a (400) Bad request error.
After some testing, the issue doesn't seem to be with the attempt to add a new virtual proxy, because I get the same error when I only pass in the proxy ID, or when I try to change something as simple as the KeepAliveTimeoutSeconds, so I believe this may be a bug with the command itself.
Code:
Connect-Qlik -TrustAllCerts -UseDefaultCredentials
$vp=New-QlikVirtualProxy -description "Vizlib Proxy" -sessionCookieHeaderName X-Qlik-Session-Vizlib -prefix vizlib -sessionCookieDomain "pmrt-qlik.com"
$p=Get-QlikProxy -filter "serverNodeConfiguration.hostName so 'qlik-sense-central0'"
echo $p.id $vp.id
Update-QlikProxy -id $p.id -virtualProxies $vp.id
Output:
buildVersion : 26.31.3.0
buildDate : 10/9/2020 09:53:45 AM
databaseProvider : Devart.Data.PostgreSql
nodeType : 1
sharedPersistence : True
requiresBootstrap : False
singleNodeOnly : False
schemaPath : About
b8545095-516a-4f93-b0fb-105c96bdd845
1b5e4f45-89de-4b5f-830d-cc4f3b860b7b
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At C:\Program Files\WindowsPowerShell\Modules\Qlik-Cli\1.21.1\functions\core.ps1:66 char:23
+ ... $result = Invoke-RestMethod @paramInvokeRestMethod @params
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I've also captured the Invoke-QlikPut data that the command generates, which looks to be fine to me:
/qrs/proxyservice/b8545095-516a-4f93-b0fb-105c96bdd845
{
"id": "b8545095-516a-4f93-b0fb-105c96bdd845",
"createdDate": "2021/10/14 20:13",
"modifiedDate": "2021/10/14 20:13",
"modifiedByUserName": "INTERNAL\\bootstrap",
"customProperties": [
],
"settings": {
"id": "b8545095-516a-4f93-b0fb-105c96bdd845",
"createdDate": "2021-10-14T20:13:39.498Z",
"modifiedDate": "2021-10-14T20:13:39.498Z",
"modifiedByUserName": "INTERNAL\\bootstrap",
"listenPort": 443,
"allowHttp": false,
"unencryptedListenPort": 80,
"authenticationListenPort": 4244,
"kerberosAuthentication": false,
"unencryptedAuthenticationListenPort": 4248,
"sslBrowserCertificateThumbprint": "",
"keepAliveTimeoutSeconds": 10,
"maxHeaderSizeBytes": 16384,
"maxHeaderLines": 100,
"logVerbosity": {
"id": "b8545095-516a-4f93-b0fb-105c96bdd845",
"createdDate": "2021-10-14T20:13:39.498Z",
"modifiedDate": "2021-10-14T20:13:39.498Z",
"modifiedByUserName": "INTERNAL\\bootstrap",
"logVerbosityAuditActivity": 4,
"logVerbosityAuditSecurity": 4,
"logVerbosityService": 4,
"logVerbosityAudit": 4,
"logVerbosityPerformance": 4,
"logVerbositySecurity": 4,
"logVerbositySystem": 4,
"schemaPath": "ProxyService.Settings.LogVerbosity"
},
"useWsTrace": false,
"performanceLoggingInterval": 5,
"restListenPort": 4243,
"virtualProxies": [
{
"id": "b8545095-516a-4f93-b0fb-105c96bdd845"
},
{
"id": "1b16e174-ae5f-4b26-a548-85bc0c53151c"
}
],
"formAuthenticationPageTemplate": "",
"loggedOutPageTemplate": "",
"errorPageTemplate": "",
"schemaPath": "ProxyService.Settings"
},
"serverNodeConfiguration": {
"id": "5af269f7-6ac2-4b1f-aae1-5c02cb6fe14f",
"name": "Central",
"hostName": "qlik-sense-central0.domain.com",
"temporaryfilepath": "C:\\Users\\QlikServiceUser\\AppData\\Local\\Temp\\",
"roles": [
{
"id": "bb6e4563-22a7-47d3-8af1-0bd78e5df023",
"definition": "SchedulerMaster",
"privileges": null
},
{
"id": "8a9e8b4e-c65b-4f4e-a54e-3da704393daa",
"definition": "LicenceMaintenance",
"privileges": null
},
{
"id": "5383fae5-4306-48de-a5b5-51173202e5d8",
"definition": "UserSync",
"privileges": null
},
{
"id": "ccaa4b8b-cec5-4c0c-a943-f5de8a6df397",
"definition": "NodeRegistration",
"privileges": null
},
{
"id": "02715fd2-178d-40a6-a87a-5abf9f7263cb",
"definition": "AppManagement",
"privileges": null
},
{
"id": "dfb5a735-676a-4b5e-a61b-a28f848d8e01",
"definition": "CleanDatabase",
"privileges": null
}
],
"serviceCluster": {
"id": "6de6e0ee-d003-4cbb-852e-1bba2e486bcc",
"name": "ServiceCluster",
"privileges": null
},
"privileges": null
},
"tags": null,
"privileges": null,
"schemaPath": "ProxyService"
}
The Function New-QlikVirtualProxy does not expose the property "sessionCookieDomain" so unless you have modified it that may be causing a error
As a work around to this, you can call the Update API Directly to workaround the missing property
$vp=New-QlikVirtualProxy -description "Vizlib Proxy" -sessionCookieHeaderName X-Qlik-Session-Vizlib -prefix vizlib -Verbose
$vp = Get-QlikVirtualProxy -id $vp.id -raw
$VP.sessionCookieDomain= "pmrt-qlik.com"
Invoke-QlikPut "/qrs/virtualproxyconfig/$($vp.id)" -body $($VP|ConvertTo-Json -Depth 5)
Testing without that property seems to work so... however you may want to look at the way you are using the Update-QlikProxy function, as if you do not provide all of the existing Virtual Proxy ID's it will remove them.
$vp = New-QlikVirtualProxy -description "Vizlib Proxy" -sessionCookieHeaderName "X-Qlik-Session-Vizlib" -prefix "vizlib"
$p = Get-QlikProxy -filter "serverNodeConfiguration.iscentral eq true" -full
$VPIDs = $p.settings.virtualProxies.id + $VP.id
$p = Update-QlikProxy -id $p.id -virtualProxies $VPIDs
Connect-Qlik -TrustAllCerts -UseDefaultCredentials
$vp=New-QlikVirtualProxy -description "Vizlib Proxy" -sessionCookieHeaderName X-Qlik-Session-Vizlib -prefix vizlib
$vp = Get-QlikVirtualProxy -id $vp.id -raw
$vp.sessionCookieDomain= "pmrt-qlik.com"
$vp = Invoke-QlikPut "/qrs/virtualproxyconfig/$($vp.id)" -body $($VP|ConvertTo-Json -Depth 5)
$p=Get-QlikProxy -filter "serverNodeConfiguration.iscentral eq true" -full
$VPIDs = $p.settings.virtualProxies.id + $vp.id
$p = Update-QlikProxy -id $p.id -virtualProxies $VPIDs
I am using a modified version of New-QlikVirtualProxy and it doesn't seem to be causing any problems, but I think I will use the method that you mentioned in the future.
Your example code didn't work for me, because the $VPIDs = $p.settings.virtualProxies.id + $vp.id
line didn't create a string array, but concatenated the ids into a single long id, but I appreciate the tip that I need to include the existing VPIDs, and I was able to get it working with the modified version of your code below:
Connect-Qlik -TrustAllCerts -UseDefaultCredentials
$vp=New-QlikVirtualProxy -description "Vizlib Proxy" -sessionCookieHeaderName X-Qlik-Session-Vizlib -prefix vizlib -sessionCookieDomain "pmrt-qlik.com"
$p=Get-QlikProxy -filter "serverNodeConfiguration.hostName so 'qlik-sense-central0'" -full
$VPIDs = @()
foreach($id in $p.settings.virtualProxies.id)
{
$VPIDs+=$id
}
$VPIDs += $vp.id
Update-QlikProxy -id $p.id -virtualProxies $VPIDs
Interestingly enough, after getting the above code working, I ran my original code, because theoretically it should have functioned exactly the same in this case, because the only VP linked to the default central proxy is the default VP, which Update-QlikProxy automatically adds to the list of proxies anyway.
Long story short, my original code is working this morning, for some reason. The instance was left running over night, and no services were restarted, so nothing should have changed, but something apparently did.