Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I am fairly new to Powershell and I have to export Qlik Sense app from our enterprise environment using AP and Poweshell.
Can anyone guide me through maybe with a sample code of how this is done please?
In our enterprise environment we use single sign-on Windows authentication, I have rootadmin level capabilitiy with my account.
I read this page here http://help.qlik.com/en-US/sense-developer/April2019/Subsystems/RepositoryServiceAPI/Content/Sense_R...
However beyond this I need help on how to write the code.
Anyone have something they can share? 🙂
I am familiar with variables, and Get commands in Powershell but probably consider myself a beginer when it comes to these activities.
Rather than reinventing the wheel you can use the Qlik-CLI PowerShell module.
https://github.com/ahaydon/Qlik-Cli
(If you have internet Access just type )
Install-Module Qlik-Cli
Then you can connect to the Qlik Sense server using
Connect-Qlik
and export the app using
Export-QlikApp -id <AppID> -filename <pathtosaveitto>
Bonjour Marc
Unfortunately we are not allowed to use that so have to use PowerShell!
Any suggestions please?
Qlik-CLI is a PowerShell module.
It is a set of pre configured scripts that simplify the process for authenticating to sense and accessing the APIs.
"We have to use PowerShell".. this is PowerShell 😁
As @Marc mentioned, Qlik-CLI is an attractive route to go for this or any PowerShell related QRS activities. It's really quite a bit easier than recreating the wheel.
Let's compare the Qlik-CLI method vs. a raw PowerShell method:
Qlik-CLI:
Connect-Qlik
Get-QlikApp -filter "name eq 'Random Data'" | Export-QlikApp -filename "$($(Get-QlikApp -filter "name eq 'Random Data'").name).qvf"
Raw PowerShell:
$hdrs = @{}
$hdrs.Add("X-Qlik-Xrfkey","examplexrfkey123")
$hdrs.Add("X-Qlik-User", "UserDirectory=INTERNAL; UserId=sa_api")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
$body = '{}'
$Data = Get-Content C:\ProgramData\Qlik\Sense\Host.cfg
$FQDN = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($($Data)))
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
$app = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/app/full?filter=(name eq 'Random Data')&xrfkey=examplexrfkey123" -Method Get -Headers $hdrs -ContentType 'application/json' -Certificate $cert
$exporttoken = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/App/$($app.id)/export/6f9e5622-7306-4b00-9da2-15b132cf7984?xrfkey=examplexrfkey123&skipdata=false" -Method Post -Body $body -Headers $hdrs -ContentType 'application/json' -Certificate $cert
Invoke-RestMethod -Uri "https://$($FQDN):4242$($exporttoken.downloadPath)" -Method Get -Headers $hdrs -ContentType 'application/json' -Certificate $cert | Set-Content "$($app.name).qvf" -Encoding Ascii
But if you have to recreate the wheel, then I have examples for GETs and POSTs on my GitHub
Hi Levi,
Is it possible to export data to excel instead of qvf using Qlik-cli?
@Kaushiki : No. Qlik-Cli-Windows accesses the RESTful APIs on Qlik Sense Enterprise Client Managed (principally the Repository API). This API does not look inside an app. Any actions which are possible via the QMC would be possible via the Repository API (and therefore Qlik-Cli-Windows). Exporting data from a table is an Engine action which is exposed via the Engine APIs (example). This is a slightly more complicated API but is possible with additional work. PowerShell would not be the appropriate language for this, instead an actual programming language like C# or NodeJS would be recommended.
Thanks Levi.
My requirement is to download qlik visualization in excel format from a non Qlik authenticated screen. Do I need to again authenticate Qlik in this screen and do the login mechanism and then export the objects? Is there any other way to export the visualizations to excel without doing the login mechanism i.e. via any scripting?