Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
djbaclay23
Contributor II
Contributor II

Anaplan API to Qlik sense using dynamic Token (store in variable)

Hi,

My Data source is Anaplan via API and I am using REST connector.

First, I already generated a Token and assign it to the variable with name vToken

using https://auth.anaplan.com/token/authenticate and Basic Auth using Username and Password

here's the initial query for that:

LIB CONNECT TO 'ANAPLAN_GEN_TOKEN';
 
RestConnectorMasterTable:
SQL SELECT 
"status",
"statusMessage",
"__KEY_root",
(SELECT 
"validationUrl",
"__FK_meta"
FROM "meta" FK "__FK_meta"),
(SELECT 
"expiresAt",
"tokenId",
"tokenValue",
"refreshTokenId",
"__FK_tokenInfo"
FROM "tokenInfo" FK "__FK_tokenInfo")
FROM JSON (wrap on) "root" PK "__KEY_root";
 
[meta]:
LOAD [validationUrl],
[__FK_meta] AS [__KEY_root]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_meta]);
 
[tokenInfo]:
LOAD [expiresAt],
[tokenId],
[tokenValue],
[refreshTokenId],
[__FK_tokenInfo] AS [__KEY_root]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_tokenInfo]);
 
[root]:
LOAD [status],
[statusMessage],
[__KEY_root]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);
 
DROP TABLE RestConnectorMasterTable;
 
LET vToken = 'AnaplanAuthToken ' &Peek('tokenValue', -1, 'tokenInfo');
 

 

 

now my problem is how I can assign the vToken dynamically to the next API connection (GET) to

load the data since the API connection is embedded to REST connector,

here's my 2nd script to load the data

RestConnectorMasterTable:
SQL SELECT 
"COLUMN1",
"COLUMN2",
"COLUMN3",
"COLUMN4"
FROM CSV (header on, delimiter "tab", quote """") "CSV_source";
 
 
[CSV_source]:
LOAD [COLUMN1],
[COLUMN2],
[COLUMN3],
[COLUMN4]
RESIDENT RestConnectorMasterTable;
 
DROP TABLE RestConnectorMasterTable;

 

 

I'm thinking how to have a custom connection or by pass the initial connection:

(https://api.anaplan.com/2/0/workspaces/testworkspacelajsd/models/testmodelasdjh/files/113000000200/c...)

to insert the $(vToken) in query headers generated from initial query at the top

 

 

 

 

Labels (3)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

Hi @djbaclay23 you can use WITH CONNECTION property for passing custom values for URL, BODY, QUERY PARAMS and HEADERS. Here an example for replacing the URL and here all the info on this property.

View solution in original post

2 Replies
alex_colombo
Employee
Employee

Hi @djbaclay23 you can use WITH CONNECTION property for passing custom values for URL, BODY, QUERY PARAMS and HEADERS. Here an example for replacing the URL and here all the info on this property.

djbaclay23
Contributor II
Contributor II
Author

it works!

Thank you