Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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)
3 Replies
Highlighted
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.

Highlighted
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

Highlighted
Contributor
Contributor

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