I have a Qlik load script where I am trying to execute a task in NPrinting. This script originated from Qlik and was working for awhile and then it stopped working. I went through the script in debug mode and narrowed it down to the step where a list of NPrinting connections was requested. I added an exit script right after the "RestConnectionMasterTable" was created to see what was in that table. As expected, I see the names of the NPrinting connections but its not a complete list. I did not find the connection that I was looking for. I went on the NPrinting server and checked that the connection existed. As a result, if I remove the exit script and let the reload continue, the connection id would be queried and used to build additional URLs. Since my connection did not exist in the table, any further REST calls will fail.
//GET the list of the connections contained in the NP App selected before RestConnectionMasterTable: SQL SELECT "__KEY_data", (SELECT "id", "name", "appId", "__FK_items" FROM "items" FK "__FK_items") FROM JSON (wrap off) "data" PK "__KEY_data" WITH CONNECTION( URL "$(v_NPRINTING_URL)/api/v1/connections", HTTPHEADER "cookie" "$(vCookie)" );
[connection_items]: LOAD [id] AS [connection_id], [name] AS [connection_name], [appId] AS [connection_appId] RESIDENT RestConnectionMasterTable WHERE NOT IsNull([__FK_items]) AND [appId] = '$(vAppId)' and upper([name]) = upper('$(v_CONN_NAME)');
//Extracts the desired Connection ID let vConnectionId = Peek('connection_id',0,'connection_items');
IF NoOfRows('connection_items') = 0 then
TRACE ERROR >>>>> Connection ID Not Found; //CALL ThrowError('Error: Connection ID Not Found') Set TriggerError; exit script; end if
//Compose the URL for the POST call that triggers a reload metadata let vReloadMetadataURL = '$(v_NPRINTING_URL)/api/v1/connections/'&'$(vConnectionId)'&'/reload';
//Compose the URL for the GET call that checks the connection status let vConnectionStatusURL = '$(v_NPRINTING_URL)/api/v1/connections/'&'$(vConnectionId)';