Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
aadil_madarveet
Partner - Creator II
Partner - Creator II

QRS API Using Powershell

Hi All,

I am trying to connect to Qlik Sense Enterprise on Windows (Feb2024 P14) using powershell. 

Does any one has any idea on why the Invoke-RestMethod throws an Unauthorized error message when passing credentials.

I am trying to apply the license on the host after installation of Qlik Sense using the /qrs/license POST call. But before making the POST call, i am trying to make a GET call to create a session cookie.

Using below headers & parameters.

$hdrs = @{
"X-Qlik-Xrfkey" = "YtgzDNRkxCjXdyut"
}
$contentType = 'application/json'
$reqUrl = https://hostname/qrs/about?xrfkey=YtgzDNRkxCjXdyut

The below request does not work and throws the error (401) Unauthorized. Even though the credential parameter has the correct credentials passed. I have verified this multiple times by logging the username and password from the credential object used here.

Invoke-RestMethod -Uri $reqUrl -Credential $cred -Method Get -Headers $hdrs -ContentType $contentType -SessionVariable websession

The below request works. But proceeds to use the loggedin users credentials. I do not want to use the logged-in users credentials as the loggedin user is not the QlikAdmin service account user, but a local windows Admin account.

Invoke-RestMethod -Uri $reqUrl -UseDefaultCredentials -Method Get -Headers $hdrs -ContentType $contentType -SessionVariable websession

Any update will help.

Labels (4)
1 Solution

Accepted Solutions
Marc
Employee
Employee

There is a PowerShell module for the QRS APIs included in the tools folder of your Qlik Sense install.
It includes functions for all the QRS APIs.

Marc_0-1744680531163.png


Assuming you have installed in the default directory.(If you copy the module Folder to another machine you can also use it to remotely connect)

Import-Module 'C:\Program Files\Qlik\Sense\Tools\QlikSenseCLI\QlikSenseCLI.psd1'
Connect-QlikSense -Credential $cred
Get-QSAbout


Connect-QlikSense -TrustAllCertificates -Hostname SomeHostName -Certificate $QlikClientCert -Username "Domain\userId"
 
you can inspect the Functions in the module by viewing the module in PowerShell ISE
Or by running `Get-Command -Module QlikSenseCli`
 
ISE is a little easier if you want to visualize the different parameter sets
Marc_1-1744680610683.png

 

View solution in original post

1 Reply
Marc
Employee
Employee

There is a PowerShell module for the QRS APIs included in the tools folder of your Qlik Sense install.
It includes functions for all the QRS APIs.

Marc_0-1744680531163.png


Assuming you have installed in the default directory.(If you copy the module Folder to another machine you can also use it to remotely connect)

Import-Module 'C:\Program Files\Qlik\Sense\Tools\QlikSenseCLI\QlikSenseCLI.psd1'
Connect-QlikSense -Credential $cred
Get-QSAbout


Connect-QlikSense -TrustAllCertificates -Hostname SomeHostName -Certificate $QlikClientCert -Username "Domain\userId"
 
you can inspect the Functions in the module by viewing the module in PowerShell ISE
Or by running `Get-Command -Module QlikSenseCli`
 
ISE is a little easier if you want to visualize the different parameter sets
Marc_1-1744680610683.png