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

Rest API connection

Hi Everyone,

I am trying to run a loop with the rest connection using the values of a field of one table. But when I am trying to do that the with connection is taking blank value for the variable I used in the loop. for more information plese go through the code and the error file attached.

code:

LIB CONNECT TO 'niki';

RestConnectorMasterTable:
SQL SELECT
"__KEY_root",
(SELECT
"nextPage",
"__KEY_result",
"__FK_result",
(SELECT
"id",
"name",
"ownerId",
"lastModified",
"creationDate",
"isActive",
"__FK_elements"
FROM "elements" FK "__FK_elements")
FROM "result" PK "__KEY_result" FK "__FK_result"),
(SELECT
"httpStatus",
"requestId",
"__FK_meta"
FROM "meta" FK "__FK_meta")
FROM JSON (wrap on) "root" PK "__KEY_root";

[elements]:
LOAD [id],
[name],
[ownerId],
[lastModified],
[creationDate],
[isActive],
[__FK_elements] AS [__KEY_result]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_elements]);


DROP TABLE RestConnectorMasterTable;

for j = 0 to 5

Let vElementID = peek([id], $(j), [elements]);

LIB CONNECT TO 'niki2';

RestConnectorMasterTable:
SQL SELECT
"__KEY_root",
(SELECT
"progressId",
"percentComplete",
"status",
"__FK_result"
FROM "result" FK "__FK_result"),
(SELECT
"requestId",
"httpStatus",
"__FK_meta"
FROM "meta" FK "__FK_meta")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(Url "https://cypress.co1.qualtrics.com/API/v3/surveys/$(vElementID)/export-responses");

[result]:
LOAD [progressId],
[percentComplete],
[status],
[__FK_result] AS [__KEY_root]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_result]);


DROP TABLE RestConnectorMasterTable;


next j;

 

When I am running this the variable v element id is taking a blank value, but there are 6 values in the field ID of element table. It would be great if someone could help me with this. Also find the error file attached.

Id error.PNG

 

Thanks in Advance,

Nithin.

2 Replies
nkumarkanduri
Contributor II
Contributor II
Author

The isseu here is the variable "velementid" in the url in the with function is considered as blank value.

nkumarkanduri
Contributor II
Contributor II
Author

The same is working fine when i am running Individually, but when I am running in loop it is not working.