Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Uday_Reddy1
Contributor III
Contributor III

Iterating over tRESTClient JSON response

Hi Team,

 

Note: I am unable to insert/upload images

 

Following is the sample JSON response from tRESTClient . I am able to get "maxResults": 500. How to get all the results by iterating programmatically.

 

tJava_1 ---on Subjob OK --->tLoop ---- Iterate ----> tJava_2 --on Component OK --> tRESRClient ---row2--> tExtractJSONFields---row1--->tJavaFlex

 

what should be java code/settings in tJava_1, tLoop, tJavaFlex components

{

   "expand": "schema,names",

   "startAt": 0,

   "maxResults": 500,

   "total": 1603,

   "issues": [

       {

           "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",

           "id": "6978451",

           "self": "https://onejira.XXXX.com/rest/api/2/issue/6978451",

           "key": "ABC-4",

           "fields": {

               "customfield_51618": null,

               "resolution": null,

               "customfield_50402": null

          }

       }

      {

           "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",

           "id": "6978452",

           "self": "https://onejira.XXXX.com/rest/api/2/issue/6978452",

           "key": "ABC-5",

           "fields": {

               "customfield_51618": null,

               "resolution": known issue,

               "customfield_50402": null

          }

       }

 ]

}

 

regards

uday

Labels (5)
2 Replies
gjeremy1617088143

Hi you have to query a first time to get the total here 1603 then you can divide by 500 so here you have 4 run of 500 and you change the 'start at' value , for each iteration to get the next 500 records

Uday_Reddy1
Contributor III
Contributor III
Author

Thanks for the answer. I got the logic, data has to be fetched as described below:

 

1st iteration:

"startAt": 0

2nd iteration:

"startAt": 500

3rd iteration:

"startAt": 1000

4th iteration:

"startAt": 1500

 

But I want to achieve programmatically, in this example we know that total records are 1603. In future if total records are >2000 job has to run 5th time.

 

So for achieving same I am using above mentioned job sequence.

 

tJava condition:

globalMap.get("startAt")<globalMap.get("total")

 

tJavaFlex settings:

globalMap.put("total", row1.total);

int startAt = (500 * ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")).intValue()) -500;

globalMap.put("startAt", startAt);