
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NPrinting API: How to execute a publish task (PowerShell)
Aug 5, 2021 6:59:33 AM
Oct 11, 2019 5:03:10 PM
This is an example of how to execute a publish task with the NPrinting API with PowerShell.
JWT authentication is used for this example.
Related Content and Resource:
Qlik NPrinting CLI (Note that Qlik NPrinting CLI is not covered by Qlik Support. Assistance for it should be obtained directly from the creators.)
Environments:
Resolution:
Run the below to run the task (It creates a task execution):
$hdrs = @{} $body = '{"priority":"10"}' $hdrs.Add("Authorization","Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6Ik...MoEtY5gCrhRSuKLg") $url = "https://qlikserver1.domain.local:4993/api/v1/tasks/35818c86-7f4e-4170-9684-6b1b7762f51b/executions" Invoke-RestMethod -Uri $url -Method Post -ContentType 'application/json' -Headers $hdrs -Body $body | ConvertTo-Json -Depth 10
35818c86-7f4e-4170-9684-6b1b7762f51b is the task id, it can be found in the NPrinting web console by opening the publish task and copy from the URL, or by calling the GET tasks API (see Qlik NPrinting API)
Example of response:
{ "data": { "id": "f4958330-9197-468e-a6c4-e311a48f08cc", "type": "Qlik.NPrinting.Task.PublishReportsEngineTask", "task": "35818c86-7f4e-4170-9684-6b1b7762f51b", "created": "0001-01-01T00:00:00Z", "lastUpdate": "0001-01-01T00:00:00Z", "completed": null, "progress": 0.0, "status": "Enqueued", "result": null, "priority": 10.0 } }
f4958330-9197-468e-a6c4-e311a48f08cc is the task execution id, it can be used to check the status of the task execution:
$hdrs = @{} $hdrs.Add("Authorization","Bearer eyJhbGciOiJSUzI1NiIsInR...MoEtY5gCrhRSuKLg") $url = "https://qlikserver1.domain.local:4993/api/v1/tasks/35818c86-7f4e-4170-9684-6b1b7762f51b/executions/f4958330-9197-468e-a6c4-e311a48f08cc" Invoke-RestMethod -Uri $url -Method Get -ContentType 'application/json' -Headers $hdrs | ConvertTo-Json -Depth 10
Example of response:
{ "data": { "id": "f4958330-9197-468e-a6c4-e311a48f08cc", "type": "Qlik.NPrinting.Task.PublishReportsEngineTask", "task": "35818c86-7f4e-4170-9684-6b1b7762f51b", "created": "2019-10-11T20:48:59.304294Z", "lastUpdate": "2019-10-11T20:49:11.381504Z", "completed": "2019-10-11T20:49:11.360501Z", "progress": 1.0, "status": "Completed", "result": null, "priority": 10.0 } }