Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
HI All,
I have succesfully setup the rest API to connect to Nprinting Setember 2019 and am able to load users,reload metadata and execute task all based on the steps provides by Gianluca_Perin in this post Nprinting API Call
I need some help though on modifying the task execution code to execute the task for a specific user when needed.
So although they may be 100s of users in the publish task I want the ability to run it just for one user. Any ideas on how this can be achieved?
The current code is below.
Get Task
RestNPTasksMasterTable:
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 "https://NPSRVR:4993/api/v1/tasks", HTTPHEADER "cookie" "$(vCookie)" );
[task_items]:
LOAD [id] AS [tasks_taskId],
[name] AS [tasks_taskName],
[appId] AS [tasks_appId]
RESIDENT RestNPTasksMasterTable
WHERE NOT IsNull([__FK_items]) AND [appId] = '$(vAppId)';
let vTaskId = Peek('tasks_taskId',0,'task_items');
let vPublshTaskURL = 'https://NPSRVR:4993/api/v1/tasks/'&'$(vTaskId)'&'/executions';
DROP TABLE RestNPTasksMasterTable;
Execute Task
LIB CONNECT TO 'NPrinting REST Login (POST) (admin)';
RestNPTaskTriggerTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");
[_post_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPTaskTriggerTable
WHERE NOT IsNull([__KEY_data]);
DROP TABLE RestNPTaskTriggerTable;
Thanks
Hi,
Running the task for 1 use via API call needs to take into consideration multiple factors:
From the list above you want to have users dynamic.
In order to achieve this I would
That being said - there is no API endpoint associating users with tasks. Instead there is an endpoint associating users with groups which you can modifiy before you trigger task and all the code is available in the link I have provided you. All what you need to do is then to feed your data in it.
regards
Lech
Hi,
Running the task for 1 use via API call needs to take into consideration multiple factors:
From the list above you want to have users dynamic.
In order to achieve this I would
That being said - there is no API endpoint associating users with tasks. Instead there is an endpoint associating users with groups which you can modifiy before you trigger task and all the code is available in the link I have provided you. All what you need to do is then to feed your data in it.
regards
Lech
btw
attaching image when this code starts. Keep in mind that using my code you would need set it up/configure to suite your environment. This because I often have to reuse the same endpoints in loops and within other procedures.
Hi Lech,
I will go through your suggestion and revert. Thank you
No worries...
So in very short:
with your script and NPrinitng APi you will preaty much:
cheers
Hi Lech,
I am able to Authenticate, I can update the user's group Let's say to (TEST GROUP) but reviewing you routine I am still not sure how to amend you TASK Execute code to only run for that specific group. Are you able to advise what changes I need to apply to the NP_GetExecutions
You setup publish task to always send report to TASK GROUP and use Api to control who belongs to it
Task execute code does have to not be amended as you always execute task and you always will send report to "TASK GROUP".
You use API to change who belongs to the group therefore based on user-group association you will send report to the person who at that moment will belong to TASK GROUP.