Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
qliklearnervir
Creator
Creator

Peek function not catching any value from SQL select table while using rest connector script

Hi all,

 

I am using standard qlik script for Rest API token generation but while loading data I am facing an issue that peek variable not catching any value from a table.

LIB CONNECT TO 'next token';

Let sessionId='';
Set nextTokenParamName='';

Do
RestConnectorMasterTable:
SQL SELECT
"Token",
"__KEY_root",
(SELECT
"_id",
"city",
"pop",
"state",
"__KEY_Items",
"__FK_Items",
(SELECT
"@Value",
"__FK_loc"
FROM "loc" FK "__FK_loc" ArrayValueAlias "@Value")
FROM "Items" PK "__KEY_Items" FK "__FK_Items")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(
QUERY "$(nextTokenParamName)" "$(sessionId)"
);

Set nextTokenParamName = 'Token';

let sessionId = peek('Token',-1,'RestConnectorMasterTable');

Trace 'The sessionId is: ' $(sessionId);

loop until $(sessionId) =''

 

so as per this code sessionid should catch the latest token value and pass it to further loop until the value becomes null.

but my peek function is not working with this SQL Select table.

please guide me as it is a very critical job failure.

2 Replies
André
Contributor II
Contributor II

I'm stuck on the exact same thing at the moment, did you ever solve this?

marcus_sommer

I doubt that there is an issue with peek() else that the loop and/or the sql didn't work like expected and therefore nothing respectively the right content for the peek() exists. Therefore split the logic in parts without a loop and with fixed values instead of the variables and adding then the more complexity step by step.