Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
satishsure
Contributor
Contributor

Get Status and completed values from NPrinting Task using REST API

Hi ,

Please help us to fetch the Status and Completed data from the NPrinting API. you can use any host & NPrinting Task Id in below url.

 

REST API : https://host/api/v1/tasks/taskid/executions

1.JPG

QLik Script:

LIB CONNECT TO 'NPrinting REST_POST';


let vPublshTaskURL = 'https://host/api/v1/tasks/'&'$(vTaskId)'&'/executions';

RestNPTaskTriggerTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");

[_post_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPTaskTriggerTable
WHERE NOT IsNull([__KEY_data]);
DROP TABLE RestNPTaskTriggerTable;

Labels (1)
1 Reply
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi, 

Your question is not detailed enough.

Do you want to get a Status and Completed for all your executions or for any particular one? Remember that the same task can have hundreds of executions and you will not know which one is which one.

in this link https://nprintingadventures.wordpress.com/2019/04/08/nprinting-api-qlik-rest-subroutines/ you will find script and subroutines which can be used to get a data you want. 

in particular you might want to focus on lines: 1417 - 1495 about   " GET LAST EXECUTION".  Note that i use it in conjuction with actual task currently running, so it is a part of another subroutine called: "SUB NP_TriggerTasks"

 
Important - since in this case it is a mixtrure of POST call and GET call notice how each time i open required caonnection method.
 
I understand that my script may not suit all your requirements, but with minor adjustments (and this is really down to qlik script logic) you will be able to change it.
cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.