Qlik Community

Knowledge

Search or browse our knowledge base to find answers to your questions ranging from account questions to troubleshooting error messages. The content is curated and updated by our global Support team

Announcements
Q&A with Qlik! New Case Portal, Chat Bot and Qlik Community. Oct. 19th REGISTER TODAY

QlikView - Call QMS API with PowerShell

Bastien_Laugiero

QlikView - Call QMS API with PowerShell


Disclaimer: The following code provided below is just an example and might need to be re-written to meet your expectation in your environment. 

You will find here how to call QMS API using PowerShell with some examples.
Please note that there are some requirements to use the QlikView Management Service API. For more detail see 
QlikView Management Service API

First of all the IQMS interface is deprecated in QlikView 12 and IQMS2 should be used instead.
For example, using IQMS in QlikView 11:
http://ws.qliktech.com/QMS/ 11/IQMS/GetTimeLimitedServiceKey
But in QlikView 12, this should be:
http://ws.qliktech.com/QMS/ 12/IQMS/GetTimeLimitedServiceKey

Using IQMS2 in QlikView 12 will look like: 
http://ws.qliktech.com/QMS/ 12/2/IQMS2/GetTimeLimitedServiceKey

Differences between IQMS and IQMS2

There are some differences in the intended use of the QMS API between QlikView 11.20 and QlikView 12.10. For these reasons, a new QMS API interface was introduced with QlikView 12.10, IQMS2, while the QMS API interface used for QlikView 11.20 is available as IQMS.
This ensures that customers who have built their clients for QlikView 11.20 can use them with no modifications when upgrading to QlikView 12.10 or later.
IQMS2 have a number of additional methods that are not available in IQMS. If you want to create a new API client on QlikView 12.10 or later, you are recommended to use IQMS2 because of the extra functionality it offers. If you downgrade to QlikView 11.20 while your API client is utilizing the IQMS2 namespace, you must change to the IQMS interface and remove all references to IQMS2 methods that are not available in IQMS.
Reference: QlikView Management Service API


Environment

  • Qlikview Server 11.20 or higher

 

Resolution:


First of all before performing a call, you need to get a Service Key. This is used for most of API calls towards the QMS API.

## URL for the QMS API endpoint 
$url = "http://servername:4799/QMS/Service" 

$service = New-WebServiceProxy -Uri $url -Namespace QlikViewServer -UseDefaultCredential 
$serviceKey = $service.GetTimeLimitedServiceKey()

In return you will get a temporary Service Key which will expired 60 seconds after it was generated. 

Now that you have the Service Key, you can reuse it perform API calls against the QMS API.
Below is an example of a script to run a task

 

$TaskID = 'a6fa2db1-3a8c-4ef4-b102-98ed30369f5d'

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/2/IQMS2/RunTask")
$hdrs.Add("Content-Type", "text/xml;charset=utf-8")
$hdrs.Add('X-Service-Key',$serviceKey)

$body = @{}
$body = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RunTask xmlns="http://ws.qliktech.com/QMS/12/2/">
<taskID>' + $TaskID + '</taskID>
</RunTask>
</s:Body>
</s:Envelope>'

$res = Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $hdrs


Run an EDX Task (This accept either the Task ID or the Task Name)

$TaskIdorName = 'test'
$EDXPassword = '123'

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/2/IQMS2/TriggerEDXTask")
$hdrs.Add('X-Service-Key',$serviceKey)

$body = @{}
$body = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<TriggerEDXTask xmlns="http://ws.qliktech.com/QMS/12/2/">
<taskNameOrID>' + $TaskIdorName + '</taskNameOrID>
<password>' + $EDXPassword + '</password>
</TriggerEDXTask>
</s:Body>
</s:Envelope>'

$res = Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $hdrs -ContentType "text/xml;charset=utf-8"



To get the list of API Calls you can perform, please have a look at: 
For IQMS: 

IQMS and IQTService Interfaces
For IQMS2:
IQMS2 and IQTService2 Interfaces

 

Labels (2)
Version history
Revision #:
3 of 3
Last update:
‎2021-05-28 02:35 PM
Updated by:
 
Contributors