<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Nprinting Rest Get user groups in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1607448#M7438</link>
    <description>&lt;P&gt;Hi Ryo_okabe,&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am trying to modify the group name of a particular user using the NP API's. I am using the put user/&amp;lt;id&amp;gt;/groups command to do so.&lt;/P&gt;&lt;P&gt;Data retrieved for Get user/&amp;lt;id&amp;gt;/groups is in the form of an array and m not sure how manipulate this.&lt;/P&gt;&lt;P&gt;But my code is failing in preparing the body request for API. Can you please help ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2019 11:36:44 GMT</pubDate>
    <dc:creator>poojask123</dc:creator>
    <dc:date>2019-07-30T11:36:44Z</dc:date>
    <item>
      <title>Nprinting Rest Get user groups</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1535570#M7435</link>
      <description>&lt;P&gt;Dear qlik developers,&lt;/P&gt;&lt;P&gt;I am trying to load a table containing all nprinting users and the groups they belong to using a script in qlik sense and a rest connection.&lt;/P&gt;&lt;P&gt;I have managed to load a table containing all the users basic information but I can't figure out how to select the groups attached to each user&lt;/P&gt;&lt;P&gt;Any help or tip would be greatly appreciated&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is&amp;nbsp;an exemple of the json structure&amp;nbsp;that i cannot address:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nprinting_get_groups.jpg" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/4587iADA9BA1173B1CB56/image-size/large?v=v2&amp;amp;px=999" role="button" title="nprinting_get_groups.jpg" alt="nprinting_get_groups.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is the script to load users details (using &lt;A href="https://community.qlik.com/t5/Qlik-NPrinting-Discussions/How-to-use-Qlik-NPrinting-APIs-inside-a-Qlik-Sense-load-script/td-p/54441" target="_self"&gt;Qlik Nprinting API&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;RestUserMasterTable:

SQL SELECT

"__KEY_data",

(SELECT

"id",
"email",
"created",
"lastUpdate", 
"enabled",
"userName",
"domainAccount",
"timezone",
"locale",
"folder",
"subFolder",
"__FK_items"

FROM "items" FK "__FK_items")

FROM JSON (wrap off) "data" PK "__KEY_data"

WITH CONNECTION( URL "https://&lt;EM&gt;&amp;lt;nprintingurl&amp;gt;&lt;/EM&gt;/api/v1/users", HTTPHEADER "cookie" "$(vCookie)" );

users_items:

LOAD 
[id] AS users_id,
[email] AS users_email,
[created] AS users_created,
[lastUpdate] AS users_lastUpdate, 
[enabled] AS users_enabled,
[userName] AS users_userName,
[domainAccount] AS users_domainAccount,
[timezone] AS users_timezone,
[locale] AS users_locale,
[folder] AS users_folder,
[subFolder] AS users_subFolder

RESIDENT RestUserMasterTable;

DROP TABLE RestUserMasterTable;



&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my draft script to load users groups .&lt;/P&gt;&lt;P&gt;The script executes itself without error but no data is loaded for field "usergroups_id"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;For i=0 to NoOfRows('users_items')-2

let vUserid= peek('users_id',$(i),'users_items');

let vUrl = 'https://&amp;lt;nprinting url&amp;gt;/api/v1/users/'&amp;amp;  '$(vUserid)'&amp;amp; '/groups' ;

RestUsersGroupsMasterTable:

SQL SELECT 

"__KEY_data",

(SELECT 

"groupids"

FROM "items" FK "__FK_items")

FROM JSON (wrap off) "data" PK "__KEY_data"

WITH CONNECTION( URL "$(vUrl)", HTTPHEADER "cookie" "$(vCookie)" );

Usergroups_items:

LOAD 

'$(vUserid)' as usergroups_user,
[groupids] as usergroups_id

Resident RestUsersGroupsMasterTable;


NEXT i&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jérôme&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 08:26:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1535570#M7435</guid>
      <dc:creator>JeromeS</dc:creator>
      <dc:date>2021-04-02T08:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Nprinting Rest Get user groups</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1535590#M7436</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why don't you try to use following sample code.&lt;/P&gt;&lt;P&gt;It works fine in my environment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is get user data.&lt;/P&gt;&lt;PRE&gt;// Get User with "usera" email
RestUserMasterTable:
SQL SELECT
"__KEY_data",
(SELECT
"id",
"email",
"__FK_items"
FROM "items" FK "__FK_items")
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "https://&amp;lt;NPServer IP&amp;gt;:4993/api/v1/users", HTTPHEADER "cookie" "$(vCookie)" );

[users_items]:
LOAD [id] AS [users_userId],
[email] AS [users_userEmail]
RESIDENT RestUserMasterTable
WHERE NOT IsNull([__FK_items]);
//Extracts the userId of the desired NP User
let vUserId = Peek('users_userId',0,'users_items');
DROP TABLE RestUserMasterTable;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is get group data and get user groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;RestGroupMasterTable:
SQL SELECT
"__KEY_data",
(SELECT 
"name",
"id",
"__FK_items",
"Created"
FROM "items" FK "__FK_items")
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "https://&amp;lt;NPServer IP&amp;gt;:4993/api/v1/Groups", HTTPHEADER "cookie" "$(vCookie)" );


[group]:
LOAD [id] AS [groups_groupId],
    [name] AS [groups_groupName]
RESIDENT RestGroupMasterTable
WHERE NOT IsNull([__FK_items]);
let vUserId = Peek('users_userId',0,'users_items');
DROP TABLE RestGroupMasterTable;


For i = 0 to NoOfRows('group')-2

let vGroupid= peek('groups_groupId',$(i),'group');

let vUrl = 'https://&amp;lt;NPServer IP&amp;gt;:4993/api/v1/Groups/'&amp;amp; '$(vGroupid)'&amp;amp; '/Users' ;

RestConnectorMasterTable:
Load @Value as [users_userId],
     '$(vGroupid)' as [groups_groupId];
SQL SELECT 
	"__KEY_data",
	(SELECT 
		"@Value",
		"__FK_items"
	FROM "items" FK "__FK_items" ArrayValueAlias "@Value")
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vUrl)", HTTPHEADER "cookie" "$(vCookie)" );

next&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 03:53:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1535590#M7436</guid>
      <dc:creator>ryo_okabe</dc:creator>
      <dc:date>2019-01-28T03:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Nprinting Rest Get user groups</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1548375#M7437</link>
      <description>&lt;P&gt;Thanks Ryookabe, it works fine &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Feb 2019 20:54:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1548375#M7437</guid>
      <dc:creator>JeromeS</dc:creator>
      <dc:date>2019-02-23T20:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Nprinting Rest Get user groups</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1607448#M7438</link>
      <description>&lt;P&gt;Hi Ryo_okabe,&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am trying to modify the group name of a particular user using the NP API's. I am using the put user/&amp;lt;id&amp;gt;/groups command to do so.&lt;/P&gt;&lt;P&gt;Data retrieved for Get user/&amp;lt;id&amp;gt;/groups is in the form of an array and m not sure how manipulate this.&lt;/P&gt;&lt;P&gt;But my code is failing in preparing the body request for API. Can you please help ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 11:36:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Nprinting-Rest-Get-user-groups/m-p/1607448#M7438</guid>
      <dc:creator>poojask123</dc:creator>
      <dc:date>2019-07-30T11:36:44Z</dc:date>
    </item>
  </channel>
</rss>

