Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Mar 25, 2021 5:29:25 AM
Jan 22, 2021 10:34:09 AM
When using an external program to run a task as described here, the execution might fail but the status of the external task in the QMC might not get updated accordingly.
In order to handle the failed execution, it's needed to send a request that updates the status in the QMC.
Here is an example of how to update the status in the QMC:
Optional step
If you want to change a specific execution you can use the following code to retrieve the ID needed to change the task status
$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User","UserDirectory=DOMAIN;UserId=Administrator")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
$url = "https://qlikserver1.domain.local:4242/qrs/executionresult?xrfkey=12345678qwertyui"
Invoke-RestMethod -Uri $url -Method get -Headers $hdrs -Certificate $cert # | ConvertTo-Json
Expected response:
id : 1fc45154-954b-497f-8752-86aca2180ec4
executingNodeName :
status : 0
startTime : 1753-01-01T00:00:00.000Z
stopTime : 1753-01-01T00:00:00.000Z
duration : 0
fileReferenceID : 00000000-0000-0000-0000-000000000000
scriptLogAvailable : False
details : {}
scriptLogLocation :
scriptLogSize : -1
privileges :
With the id retrieved we can go ahead and change the result:
$body = '{
"status":"11",
"modifiedDate":"2021-03-25T17:00:36.157Z"
}'
$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User","UserDirectory=DOMAIN;UserId=Administrator")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
$url = "https://qlikserver1.domain.local:4242/qrs/executionresult/1fc45154-954b-497f-8752-86aca2180ec4?xrfkey=12345678qwertyui"
Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs -Certificate $cert -Body $body -ContentType 'application/json'
"0: NeverStarted",
"1: Triggered",
"2: Started",
"3: Queued",
"4: AbortInitiated",
"5: Aborting",
"6: Aborted",
"7: FinishedSuccess",
"8: FinishedFail",
"9: Skipped",
"10: Retry",
"11: Error",
"12: Reset"
Connecting with Microsoft Powershell
Qlik Sense - Create an external program running a Powershell Script