Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
I'm successfully using APIs from Sense to get some info around users, groups and tasks etc in Nprinting, however I'm really struggling to figure out how to get a recipient list from a publish task.
I'd like to be able to get this via API into a Sense App for ease of reference.
Can this be achieved?
Thanks in advance!
Hi Mike,
You are struggling because it is not possible. There is no endpoint to do that at the moment. I am sure you read this so attaching this as a reference for others who did not: https://help.qlik.com/en-US/nprinting/June2020/APIs/NP+API/index.html
The not supported/not recommended workaround is to connect to postgreSQL repository database and get that relationship from there - Like this: https://community.qlik.com/t5/Qlik-NPrinting-Discussions/Overview-Users-per-task-in-NPrinting/td-p/1...
Cheers
Lech
Hi Mike,
You are struggling because it is not possible. There is no endpoint to do that at the moment. I am sure you read this so attaching this as a reference for others who did not: https://help.qlik.com/en-US/nprinting/June2020/APIs/NP+API/index.html
The not supported/not recommended workaround is to connect to postgreSQL repository database and get that relationship from there - Like this: https://community.qlik.com/t5/Qlik-NPrinting-Discussions/Overview-Users-per-task-in-NPrinting/td-p/1...
Cheers
Lech
Thanks for the confirmation. Much appreciated.
I suggest using the NPE endpoint (unsupported and not documented) instead @mikeslade . Its the same endpoints that WC uses. I dont have the exact url in my head but bring up dev console when browsing WC and publish task and you will find it. Ping me if you can't find it and i will retrieve it for you (i should have some code lying around somewhere :))
Hi @blaise - very good point, thanks for this advice
you just made me think that there is a room for extended version of not supported scripts i could write to query NPE endpoints... I did my first tests and all parameters seem to work nice including number of returned records etc...
Using the same approach as with supported api I created 2 connection to authenticate endpoint get and post and using WITH CONNECTION I could perform call to pull recipients attached to task. I guess I could just loop through tasks now to get full list
getting cookie variable:
LIB CONNECT TO 'API_NPE_POST';
RestConnectorMasterTable:
SQL SELECT
"Access-Control-Allow-Credentials",
"Access-Control-Allow-Origin",
"Content-Encoding",
"Content-Security-Policy",
"Cache-Control",
"Content-Type",
"Date",
"Set-Cookie",
"Server",
"X-Frame-Options",
"Content-Length",
"__KEY__response_header",
(SELECT
"result",
"code",
"message",
"__FK_root"
FROM (wrap on) "root" FK "__FK_root")
FROM JSON "_response_header" PK "__KEY__response_header";
[_response_header]:
LOAD
[Access-Control-Allow-Credentials],
[Access-Control-Allow-Origin],
[Content-Encoding],
[Content-Security-Policy],
[Cache-Control],
[Content-Type],
[Date],
[Set-Cookie],
[Server],
[X-Frame-Options],
[Content-Length],
[__KEY__response_header]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY__response_header]);
DROP TABLE RestConnectorMasterTable;
Let vCookieRaw = Peek('Set-Cookie',0,'_response_header');
Trace Loading cookie based on NPrinting version equal or post Feb 2020 SR1 release;
Let vCookie = TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',2);
// Trace
Trace ---;
Trace Raw Session Cookie: "$(vCookieRaw)";
Trace Truncated Session Cookie: "$(vCookie)";
;
DROP TABLE [_response_header];
getting users from task (currently hardcoded to pull recipients from task 9d16646b-bda0-4862-bb06-810b44392092, but easy to parameterize)
LIB CONNECT TO 'API_NPE_GET';
Let vURL_GetTaskUsers = 'https://$(NP_Server):4993/npe/tasks/publish/9d16646b-bda0-4862-bb06-810b44392092/recipients?count=100&orderBy=%2Brecipient.name&page=1&sorting%5Brecipient.name%5D=asc';
RestConnectorMasterTable:
SQL SELECT
"__KEY_root",
(SELECT
"__KEY_result",
"__FK_result",
(SELECT
"id" AS "id_u0",
"enabled",
"recipientId",
"webDestinationActive",
"smtpDestinationActive",
"__KEY_list",
"__FK_list",
(SELECT
"id",
"version",
"name",
"description",
"isGroup",
"isUser",
"__FK_recipient"
FROM "recipient" FK "__FK_recipient")
FROM "list" PK "__KEY_list" FK "__FK_list")
FROM "result" PK "__KEY_result" FK "__FK_result")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH
CONNECTION( URL "$(vURL_GetTaskUsers)", HTTPHEADER "cookie" "$(vCookie)", QUERY "Limit" "$(vQueryLimit)" )
;
[recipient]:
LOAD
[id],
[version],
[name],
[description],
[isGroup],
[isUser],
[__FK_recipient] AS [__KEY_list]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_recipient]);
DROP TABLE RestConnectorMasterTable;
ohh my gosh - this will be busy weekend 😛
cheers guys 🙂
@mikeslade - I apologize for my blunt previous comment that info you were searching is not available via api call... As it turned out it is available, but API is not really documented nor officially supported. Regardless, @blaise 's post inspired me to play little bit with it - so stay tuned as there will be something coming soon.
Cheers
Lech