Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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!

1 Reply
Jeff
Partner - Contributor
Partner - Contributor

Were you able to resolve the issue? I am having similar issue using Postman where it simply returns 403 forbidden