The purpose of this article is to show how to assign Qlik cloud licenses using the REST Connector.
Prerequisites:
//
//How to ADD Licenses using the rest connector
//
// Subject IDP, Can be retrieved via API https://qlik.dev/apis/rest/users/#%23%2Fentries%2Fv1%2Fusers-get
LET vsubject = 'auth0|82c666044a1f359ff49dcc9ac8200';
let vRequestBody ='{';
Let vRequestBody = vRequestBody&'"add":[{';
//type of license assigned it can be "professional" or "analyzer"
Let vRequestBody = vRequestBody&'"type":"professional",';
Let vRequestBody = vRequestBody&'"subject":"$(vsubject)"';
Let vRequestBody = vRequestBody&'}]';
Let vRequestBody = vRequestBody&'}';
let vRequestBody = replace(vRequestBody,'"', chr(34)&chr(34));
//Endpoint used can be found here : https://qlik.dev/apis/rest/licenses/#%23%2Fentries%2Fv1%2Flicenses%2Fassignments%2Factions%2Fadd-pos...
LIB CONNECT TO 'licensesassignmentsactionsadd';
RestConnectorMasterTable:
SQL SELECT
"url",
"__KEY_root",
(SELECT
"add",
(SELECT
"type",
"subject"
FROM "add" )
FROM "data"
)
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(
BODY "$(vRequestBody)"
);
*Notes: The license assignment is based on the subject IDP. That information can be retrieved manually using the management console or using the API for users.
How to Generate API Keys in Qlik Sense SaaS using APIs
Assigning user roles
Assigns license access to the given users API