- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bad Exported file (call export api in qlik sense)
I export an app with these commands by PowerShell but when I try to open it in Qlik Sense desktop it says: "unsupported file format"
$hdrs = @{} $t = "22cde6c8-30b7-11ea-978f-2e728ce88125"
|
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you used code I wrote, apologies 😀. This is running for me:
$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=true" -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 -OutFile "$($app.name).qvf"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you used code I wrote, apologies 😀. This is running for me:
$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=true" -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 -OutFile "$($app.name).qvf"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would you please say I Should have this file by default?
C:\ProgramData\Qlik\Sense\Host.cfg
Or should I generate by myself? if yes, what should I write inside it?
And Can I ask where it will be saved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is the base64 encrypted file which lists the hostname for the Qlik site. The code is written to be run on the server but dynamically connect no matter what Qlik is installed as. If you know the hostname, you can statically define is a variable in the PowerShell code on your end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. my problem solved. your code is great.
and the main problem was about putting values in variable so if I write the file like your command it will be solve.
Invoke-RestMethod -Uri $url -Method Get -Headers $hdrs -ContentType 'application/json' -Certificate $cert -OutFile $output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found this:
https://github.com/levi-turner/QlikSenseScripts
It is great. But I can't find any file for "import". Do you have any sample for import?
I wrote this but it has 400 (bad request) error
$Body = @{
filename="test_import.qvf"
} | ConvertTo-Json
$url = "https://XXX:4242/qrs/app/import?name=test_import&xrfkey=1234567890123456"
$response = Invoke-RestMethod -Uri $url -Method POST -Headers $hdrs -Certificate $cert -Body $Body -ContentType 'application/json'
$response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please create a separate thread for this ask.