Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

subhalaxmi_rout
New Contributor

Not able export Qlik Sense application using power shell scripting

Hello All,

I tried to export Qlik sense application using below power shell script. But I am getting "HTTP 403 Forbidden" error.

add-type @"

        using System.Net;

        using System.Security.Cryptography.X509Certificates;

        public class TrustAllCertsPolicy : ICertificatePolicy {

          public bool CheckValidationResult(

            ServicePoint srvPoint, X509Certificate certificate,

            WebRequest request, int certificateProblem) {

            return true;

          }

        }

"@

[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 ("Certificate path\client.pfx", "Migrate2018")

$xrfkey = 'somerandomstring'

$headers = @{"X-Qlik-User"="UserDirectory=INTERNAL;UserId=sa_repository"; "X-Qlik-Xrfkey"=$xrfkey; }

$base = "Destination-File path"

$qrshost = "Host-Name"

$apps = Invoke-WebRequest "https://$( $qrshost ):4242/qrs/app/full?Xrfkey=$xrfkey" -Certificate $certificate -Headers $headers

$apps.Content | Out-File -FilePath "$base\apps.json" -Force

foreach($app in ($apps | ConvertFrom-Json)){

$exporttoken = Invoke-WebRequest "https://$( $qrshost ):4242/qrs/app/$( $app.id )/export?Xrfkey=$xrfkey" -Certificate $certificate -Headers $headers -TimeoutSec 999 | ConvertFrom-Json

Invoke-WebRequest "https://$( $qrshost ):4242/qrs/download/app/$( $app.id )/$( $exporttoken.value )/$( $app.id )?Xrfkey=$xrfkey" -Certificate $certificate -Headers $headers | Out-File -FilePath "$base\apps\$( $app.id ).qvf" -Force

}

Thanks!