Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

NPrinting API: How to execute a publish task (PowerShell)

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

NPrinting API: How to execute a publish task (PowerShell)

Last Update:

Aug 5, 2021 6:59:33 AM

Updated By:

Sonja_Bauernfeind

Created date:

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
             }
}

 

Labels (1)
Contributors
Version history
Last update:
‎2021-08-05 06:59 AM
Updated by: