Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Woojtek_96
Contributor III
Contributor III

Retrive Group users info from Nprinting API

Hi all, 

I'm trying to retrive info about users in my groups from NPrinting API.

I stuck at:

Woojtek_96_0-1649664285604.png

So far I managed to retrive info about tasks, users, groups. In this request I want to retrive users from particular group.
In place where I load data i have to select desired fields but when i write "guid" i don't have any resposne. The same is for Guid, guId, GuID etc. I had tried many combinations.
For example when I was retriving info for users i have field named "UserName" but in qlik script field name is "userName" finally worked

 I had readed many websites and topics on this forum and didn't find anything helpful.
Other case is to know which fields I'm getting from API, I can't make select * so maybe some kind of for.. each?
but I don't know how to write it (in Select Statement?)
In addition i'm pasting my QV script:

Woojtek_96_2-1649664751174.png


Thanks for all help

Labels (2)
1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Since you already have the user IDs, you can use something like this:

LET vAllGroups = 'https://server:4993' & '/api/v1/users/' & '$(vNPUserID)' & '/groups' ;

... do something ...

For example, to add a user to a group

Table:
SQL SELECT
"__KEY_data"
FROM JSON "data" PK "__KEY_data"
WITH CONNECTION
(
URL "$(vAllGroups)",
BODY "$(vGroupIDs)", //ID or IDs of groups
HTTPHEADER "Origin" "$(vQlikSenseServer)",
HTTPHEADER "Content-Type" "application/json",
HTTPHEADER "X-HTTP-Method-Override" "PUT",
HTTPHEADER "cookie" "$(vCookie)",
QUERY "Limit" "1000000"
);

Some other good examples here: https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/td-p/1535570

 

 

View solution in original post

6 Replies
JHuis
Creator III
Creator III

Woojtek_96
Contributor III
Contributor III
Author

Unfortunately, I didn't find any useful info in this links. But thank you very much for help

Miguel_Angel_Baeyens

Take the examples from here: 

https://community.qlik.com/t5/Qlik-NPrinting-Discussions/How-to-use-Qlik-NPrinting-APIs-inside-a-Qli...

Although it refers to Qlik Sense script, the logic and syntax is all valid except for the data connection.

Woojtek_96
Contributor III
Contributor III
Author

@Miguel_Angel_Baeyens  I Based on this with creating tables for  authentication, tasks andusers. But in this doc there isn't anything about groups

Miguel_Angel_Baeyens

Since you already have the user IDs, you can use something like this:

LET vAllGroups = 'https://server:4993' & '/api/v1/users/' & '$(vNPUserID)' & '/groups' ;

... do something ...

For example, to add a user to a group

Table:
SQL SELECT
"__KEY_data"
FROM JSON "data" PK "__KEY_data"
WITH CONNECTION
(
URL "$(vAllGroups)",
BODY "$(vGroupIDs)", //ID or IDs of groups
HTTPHEADER "Origin" "$(vQlikSenseServer)",
HTTPHEADER "Content-Type" "application/json",
HTTPHEADER "X-HTTP-Method-Override" "PUT",
HTTPHEADER "cookie" "$(vCookie)",
QUERY "Limit" "1000000"
);

Some other good examples here: https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/td-p/1535570

 

 

Woojtek_96
Contributor III
Contributor III
Author

@Miguel_Angel_Baeyens  This is what i looking for.

Thank you very much and have a nice day