Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!

QlikView - Call QMS API with PowerShell

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Bastien_Laugiero

QlikView - Call QMS API with PowerShell

Last Update:

May 28, 2021 2:35:55 PM

Updated By:

Andre_Sostizzo

Created date:

May 28, 2018 6:43:26 AM


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)
Comments
BuTbka
Creator
Creator

Thanks!
But why doesn't this code work?

$url = "http://qlikview:4799/QMS/Service" 

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

$qdsID = 'b01df110-bc40-48d2-8173-07da9677f273'
$taskID = 'c22fa0f8-ae97-42bc-ad1e-70076c908c4a'

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/7/IQMS7/GetExternalProgramTask")
$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>
<GetExternalProgramTask xmlns="http://ws.qliktech.com/QMS/12/7/">
<qdsID>' + $qdsID + '</qdsID>
<taskID>' + $taskID + '</taskID>
</GetExternalProgramTask>
</s:Body>
</s:Envelope>'

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

Hello @BuTbka 

Please post your query with as much detail as possible in the appropriate forum. We cannot provide further guidance directly in this article, and posting the correct forum will make your post visible to our large user base and our active support agents.

All the best,
Sonja 

Contributors
Version history
Last update:
‎2021-05-28 02:35 PM
Updated by: