
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- « Previous Replies
-
- 1
- 2
- Next Replies »

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- those characters appear when copying my code from community to Qlik Sense
- the correct characters are shown above no 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
You run the GET and in the answer you will see that information:
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ruggero,
Please find the attachments. NPrinting Last cache update not showing correctly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ruggero,
API NOT even showing year 2022 for any connections.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)

- « Previous Replies
-
- 1
- 2
- Next Replies »