Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
sabari1910
Contributor III
Contributor III

NPrinting API

Dear Qlik Experts,

I'm trying to get NPrinting Connections details using REST API but I unable to fetch connection metadata last reload (Last cache update) details.

Can someone please help immediately on this.

Thanks,

G.Sabarirajan

Labels (2)
12 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

i have given you the exact script in my blog comments (not sure If you have seen this). If not got to https://nprintingadventures.com/2019/04/08/nprinting-api-qlik-rest-subroutines/ download and configure script to read NPrinitng.qvs adn follow additional steps:

So the process will be:

  • You need to get Authenticated. You can use for this my NPrinting.qvs
    • Include NPrinting,qvs and call authentication
    • $(Must_Include='$(vConnection)\Script\NPrinting.qvs');
      Call NP_Authenticate​
  • Then run below script and adjust variables accordingly for your NPrinting server and connection ID you want to check:
    • Let vConnectionStatusURL = 'https://$(vNPrintingServer):4993/api/v1/connections/$(vConnectionId)';
      
      LIB CONNECT TO '$(vConnection_GET)';
      
      RestConnectionStatusTable:
      SQL SELECT
      “id”,
      “name”,
      “description”,
      “created”,
      “lastUpdate”,
      “appId”,
      “source”,
      “connectionString”,
      “notificationsEnabled”,
      “cacheStatus”,
      “connectionStatus”
      FROM
      JSON (wrap off) "data"
      WITH
      CONNECTION( URL "$(vConnectionStatusURL)", HTTPHEADER "cookie" "$(vCookie)", QUERY "Limit" "$(vQueryLimit)")
      ;

cheers

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.
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

by the way - please note that when you copy from community double quote characters "" are replaced with some other characters causing issues - make sure you update those characters so they are actual double quotes:

  1. those characters appear when copying my code from community to Qlik Sense
  2. the correct characters are shown above no 2

Lech_Miszkiewicz_0-1644913849188.png

 

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.
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Attached below is modified and simplified code when using my NPrinting.qvs. You could simply put SUB  NP_CheckConnectionStatus into my NPrinting.qvs and then just call

  • Call NP_Authenticate
    Call NP_GetAppID('Testing Only')
    Call NP_CheckConnectionStatus('Testing Only')

Otherwise you can have it like this:

 		$(Must_Include='$(vConnection)\Script\NPrinting.qvs');

 		SUB NP_CheckConnectionStatus(vNPrintingConnectionName)
        
                //  Get Connections
                Call NP_GetConnections('$(vNPrintingConnectionName)')

                    FOR Each  vRowNo in FieldValueList('connection_row_no');  

                        //	Extracts the desired Connection ID
                
                        Let vConnectionId               = Peek('connection_id',$(vRowNo)-1,'connection_items');
                        Let vNPrintingConnectionName    = Peek('connection_name',$(vRowNo)-1,'connection_items');
                        //	Trace            
                        Trace 	---;
                        Trace 	Derived ConnectionId for Connection '$(vNPrintingConnectionName)' is '$(vConnectionId)';

                        //  Compose the URL for the GET call that checks the connection status

                        Let vConnectionStatusURL    = 'https://$(vNPrintingServer):4993/api/v1/connections/$(vConnectionId)';
                        Trace Connection Status URL: ;
                        Trace "$(vConnectionStatusURL)" ;

                        //  Check Connection Data
                    
                        LIB CONNECT TO '$(vConnection_GET)'; 
                                        
                        RestConnectionStatusTable:
                        SQL SELECT
                            "id",
                            "name",
                            "description",
                            "created",
                            "lastUpdate",
                            "appId",
                            "source",
                            "connectionString",
                            "notificationsEnabled",
                            "cacheStatus",
                            "connectionStatus"
                        FROM 
                            JSON (wrap off) "data"
                        WITH 
                            CONNECTION( URL "$(vConnectionStatusURL)", HTTPHEADER "cookie" "$(vCookie)", QUERY "Limit" "$(vQueryLimit)")
                        ;  
                        
                        ConnectionData:
                        LOAD	
                            [id],
                            [name],
                            [description],
                            [created],
                            LocalTime([lastUpdate],'Sydney') as LastUpdateLocal,
                            [lastUpdate],
                            [appId],
                            [source],
                            [connectionString],
                            [notificationsEnabled],
                            [cacheStatus],
                            [connectionStatus]
                        RESIDENT RestConnectionStatusTable;

						DROP TABLE RestConnectionStatusTable;
                        
                    Next
			EndSub
			
            Call NP_Authenticate
            Call NP_GetAppID('Testing Only')
            Call NP_CheckConnectionStatus('Testing Only')
            
        	exit script;

 

And the result is:

Lech_Miszkiewicz_1-1644914878117.png

 

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.
Ruggero_Piccoli
Support
Support

Hi,

The API https://help.qlik.com/en-US/nprinting/June2020/APIs/NP+API/index.html?page=13 returns also the lastUpdate information of a connection.

For example this connection:

Ruggero_Piccoli_0-1644921320556.png

You run the GET and in the answer you will see that information:

Ruggero_Piccoli_1-1644921474712.png

If this doesn't work in your installation please post more details about what you are doing and the errors you get.

Best Regards,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
sabari1910
Contributor III
Contributor III
Author

Hi Ruggero,

Please find the attachments. NPrinting Last cache update not showing correctly.

 

sabari1910
Contributor III
Contributor III
Author

Hi Ruggero,

API NOT even showing year 2022 for any connections.

Ruggero_Piccoli
Support
Support

Hi,

This is very strange, I'm not aware of similar issues. So I would like to suggest to upgrade to latest version (May 2021 SR3) and test with it. Be also 100% sure you are connecting POSTMan to the correct server and apps because it is very strange.

Best Regards,

Rugger



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
sabari1910
Contributor III
Contributor III
Author

Thanks Rugger.

@Lech_Miszkiewicz  Any suggestions pls. 

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Agree wth @Ruggero_Piccoli 

it works for me, so the only things i can think of is that you may be using older version or connecting to different server (unlikely)

 

 

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.