Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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:
$(Must_Include='$(vConnection)\Script\NPrinting.qvs');
Call NP_Authenticate
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
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:
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
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:
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
Hi Ruggero,
Please find the attachments. NPrinting Last cache update not showing correctly.
Hi Ruggero,
API NOT even showing year 2022 for any connections.
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
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)