Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
alexndr
Contributor
Contributor

[QRS API] API Calls with Powershell

Hi, 

On Dev Hub\Engine API there is an option to extract App Load Script using following request: 
{
   "handle": 1,
   "method": "GetScript",
   "params": {}
}

Response: 
{
   "jsonrpc": "2.0",
   "id": 3,
   "delta": true,
   "result": {
       "qScript": "///$tab Main\r\nSET ThousandSep=',';\r\nSET DecimalSep='.'; .....
   }
}

My aim is to get list of all applications on server and extract load script for each of them into file.

So i'm interesting how to call same method using Powershell. 

Does anybody know how to implement this?

Labels (3)
1 Solution

Accepted Solutions
Marc
Employee
Employee

In the script posted on the following.

https://community.qlik.com/t5/Integration-Extension-APIs/edit-script-load-editor-with-net-SDK/m-p/17...

near the end there is a step that gets the script, modifies the script then puts it back on the server.

#Once we have the App we can Get the Load Script
$AppScript = $QEApp.GetScript()

if you remove modify and update steps you could just do something such as this to output it. 

#Once we have the App we can Get the Load Script
$AppScript = $QEApp.GetScript()

$AppScript|out-file "C:\pathto\$($AppID)_script.txt"

 

View solution in original post

5 Replies
Levi_Turner
Employee
Employee

I am curious whether others have solved for this. The crux of the issue is that the request to the Engine neither goes over QRS nor is it a RESTful call. It's a request over a websocket which there isn't native PowerShell support for. There are likely ways to accomplish this by using C# or .NET code but it would increase the complexity of the solution.

dxa
Employee
Employee

Hello!

You can do this with corectl

With corectl installed you can do the following:

corectl context create <name> --engine <QSEoW-URL>

corectl context use <name>

corectl context login (This will prompt you for your user credentials)

After that you should be able to validate that you've got it setup by running

corectl status  (It should say something like "Connected without app.... ")

 

Now I'm not a PowerShell guru but I can give you the puzzle pieces, or rather, this is how I'd do it in shellscript:

for id in $(corectl app ls -q); do corectl --app $id script get > $id.qvs; done

 

"corectl app ls -q" will give you all the IDs of the apps. "corectl --app <APPID/APPNAME> script get" will give you the script of that specific file.

Hope this helps.

Cheers

alexndr
Contributor
Contributor
Author

Thanks for your reply. I will check it ASAP. I have a lot of security restrictions

corriebyrd
Contributor
Contributor

Find a solution to this? I have hundreds of dashboards that I need to retrieve the script from. 

Marc
Employee
Employee

In the script posted on the following.

https://community.qlik.com/t5/Integration-Extension-APIs/edit-script-load-editor-with-net-SDK/m-p/17...

near the end there is a step that gets the script, modifies the script then puts it back on the server.

#Once we have the App we can Get the Load Script
$AppScript = $QEApp.GetScript()

if you remove modify and update steps you could just do something such as this to output it. 

#Once we have the App we can Get the Load Script
$AppScript = $QEApp.GetScript()

$AppScript|out-file "C:\pathto\$($AppID)_script.txt"