Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
$req = New-Object System.Net.WebClient
$req.Method = "GET";
$req.UserAgent = "Windows";
$req.Accept = "application/json";
$req.Credentials = [System.Net.CredentialCache]::DefaultCredentials;
$req.Headers.Add("X-Qlik-xrfkey", "ABCDEFG123456789");
$req.DownloadString("https://url:12345/qrs/about?xrfkey=ABCDEFG123456789");
anyone can help with? what i'm missing?
What is port 12345? Is this the QRS port (4242) or the Proxy HTTPS port (443)? If it's 443, then is the default virtual proxy setup for Forms auth?
Sample .ps1 since I couldn't get your code to run:
$hdrs = @{}
$hdrs.Add("X-Qlik-Xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User", "UserDirectory=INTERNAL; UserId=sa_api")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
$myFQDN=(Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
$myFQDN = $myFQDN.ToLower()
Invoke-RestMethod -Uri "https://$($myFQDN):4242/qrs/about?xrfkey=12345678qwertyui" -Method Get -Headers $hdrs -ContentType 'application/json' -Certificate $cert'
Likewise, what is the response from Powershell?
i don't need to do something with a certificate right? because i'm executing the PS1 script under the same account as service account of Qlik Sense services.
ABCDEFG123456789 key i create random ofcourse.
What is port 12345? Is this the QRS port (4242) or the Proxy HTTPS port (443)? If it's 443, then is the default virtual proxy setup for Forms auth?
Sample .ps1 since I couldn't get your code to run:
$hdrs = @{}
$hdrs.Add("X-Qlik-Xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User", "UserDirectory=INTERNAL; UserId=sa_api")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
$myFQDN=(Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
$myFQDN = $myFQDN.ToLower()
Invoke-RestMethod -Uri "https://$($myFQDN):4242/qrs/about?xrfkey=12345678qwertyui" -Method Get -Headers $hdrs -ContentType 'application/json' -Certificate $cert'
Likewise, what is the response from Powershell?
12345 is my https port which i changed in qmc (instead of 443)
from my code the result is that i get some kind of java/html login page (code).
form is not default. Default is from installation: Central Proxy (Default) Ticket/Windows
your code gives this error:
Invoke-RestMethod : The remote server returned an error: (403) Forbidden.
At line:14 char:1
+ Invoke-RestMethod -Uri "https://$($myFQDN):4242/qrs/about?xrfkey=12345678qwertyu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
works now thanks