QlikSense - REST API chain call - script
QlikSense - REST API chain call - script
I need to integrate data in my Qlik Sense project using cloud REST api. I need to call a chain of API as I firstly need the Token
Basically:
1) "Token" REST passing user+psw getting token
2) "API2" REST passing token received from 1 in the BODY
I successfully created the script for generate the code:
RestConnectorMasterTable:
SQL SELECT
"token",
"__KEY_root"
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(BODY "$(vRequestBody)");
[root]:
LOAD [token] AS [token]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);
DROP TABLE RestConnectorMasterTable;
My problem is that I don't uderstand how to use [token] as a variable to pass in the 2 call.
If I use:
let tokenizer = [token]
I does not work.
Any idea?
Thx
1 Answer
1
If i undestand well your question, you need to get a token from the first call to use it in the second call.
the simple way is to use lookup function to get your token :
let validToken = lookup('token', '__KEY_root', 1 ,'root');
then in your second request
'SELECT
"_scroll_id",
"__KEY_root",
(SELECT
"__FK_hits",
(SELECT
(SELECT
$(Fields)
FROM "_source" FK "__FK__source")
FROM "hits" PK "__KEY_hits_u0" FK "__FK_hits_u0")
FROM "hits" PK "__KEY_hits" FK "__FK_hits")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(
Url "$(url)",
BODY "$(validToken)"
)';
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
That's exactly what I need! thanks!!!
– user3925023
Sep 18 '18 at 8:47