<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to loop a tRestClient to fetch all data in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2456382#M140686</link>
    <description>&lt;P&gt;Hi Shicong,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got my loop working already. Thank you for all your help.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is what my job looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jhammagisa_0-1716756459594.png" style="width: 696px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/166856i8D6D1BFA4F571968/image-dimensions/696x141?v=v2" width="696" height="141" role="button" title="jhammagisa_0-1716756459594.png" alt="jhammagisa_0-1716756459594.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 26 May 2024 20:48:00 GMT</pubDate>
    <dc:creator>jhammagisa</dc:creator>
    <dc:date>2024-05-26T20:48:00Z</dc:date>
    <item>
      <title>How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2452936#M140647</link>
      <description>&lt;P&gt;I aim to retrieve all the data from our Freshdesk ticketing system. However, I've encountered a limitation with the API, which only permits a maximum of 100 data entries per page.&lt;/P&gt;
&lt;P&gt;As we have over 1,000 contacts to gather and store in our database, I'm currently facing a challenge in looping back to the tRESTClient to fetch the next set of data and appending it to my CSV file.&lt;/P&gt;
&lt;P&gt;Here's my current setup: tRESTClient -&amp;gt; tXMLMap -&amp;gt; tLogRow -&amp;gt; tFileOutputDelimited. My end goal is to be able to fetch all the contact details and store it to our MySQL DB.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am very new at using Talend so any guidance on how to proceed would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 23:49:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2452936#M140647</guid>
      <dc:creator>jhammagisa</dc:creator>
      <dc:date>2024-05-15T23:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2452978#M140648</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;There has been some similar topics on community, we usually use tLoop make a loop, set the limit &amp;amp; offset parameters to control the number of records retrieved each time until all records are retrieved and the loop ends. Please get more information about your API and check if these parameters are available.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Shicong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 04:54:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2452978#M140648</guid>
      <dc:creator>Shicong_Hong</dc:creator>
      <dc:date>2024-05-16T04:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2453420#M140655</link>
      <description>&lt;P&gt;Hi Shicong,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your reply.&lt;/P&gt;
&lt;P&gt;The API we're working with doesn't provide information about the total number of data or the number of pages available. Our current approach involves using a variable called "pageCount" and implementing an if statement. If the condition "tLogRow nb_line &amp;lt;= 100 and tLogRow nb_line != 0" is met, we'll increment the pageCount by 1 and loop back to the tRestClient to retrieve the data from the next page.&lt;/P&gt;
&lt;P&gt;The URL structure we're using is {baseUrl}api/v2/contacts?page=1&amp;amp;per_page=100, where we need to update the page number with each loop iteration.&lt;/P&gt;
&lt;P&gt;I'm currently facing challenges in setting up the pageCount parameter for the tRestClient to read, and also connecting the loop back to the tRestClient. I've reviewed similar posts and attempted the suggested solutions, but unfortunately, they haven't resolved our issue so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 01:53:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2453420#M140655</guid>
      <dc:creator>jhammagisa</dc:creator>
      <dc:date>2024-05-17T01:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2453548#M140658</link>
      <description>&lt;P&gt;You can define a context variable for page number called pageNumber, &lt;STRONG&gt;int&lt;/STRONG&gt; type, default value as &lt;STRONG&gt;1&lt;/STRONG&gt;, and set a dynamic URL:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"{baseUrl}api/v2/contacts?page="+context.pageNumber+"&amp;amp;per_page=100"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use a tLoop with &lt;STRONG&gt;For&lt;/STRONG&gt; type to make a loop, define a context variable (&lt;STRONG&gt;boolean&lt;/STRONG&gt; type, default value as "&lt;STRONG&gt;true&lt;/STRONG&gt;") called "condition" and use this context variable in the &lt;STRONG&gt;Condition&lt;/STRONG&gt; field.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Shicong_Hong_0-1715936297371.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/166301i3249F0F33C19AD89/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Shicong_Hong_0-1715936297371.png" alt="Shicong_Hong_0-1715936297371.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;A simple job looks like:&lt;/P&gt;
&lt;P&gt;tLoop--iterate--tRestClient-&lt;SPAN&gt;-&amp;gt; tXMLMap -&amp;gt; tFileOutputDelimited_1--oncomponentok--tJava&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;on tJava:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;int number_of_records=((Integer)globalMap.get("tFileOutputDelimited_1_NB_LINE"));

if(number_of_records&amp;lt;=100&amp;amp;&amp;amp;number_of_records!=0){

context.pageNumber=context.pageNumber+1;

}else{
context.condition=false;
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please have a try and let me know if you have any issues/questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 09:09:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2453548#M140658</guid>
      <dc:creator>Shicong_Hong</dc:creator>
      <dc:date>2024-05-17T09:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2455639#M140678</link>
      <description>&lt;P&gt;Hi Shicong&lt;/P&gt;
&lt;P&gt;Thank you so much for your help. I was able to make the loop work and store all the data in my database, thanks to your guidance.&lt;/P&gt;
&lt;P&gt;I now have another issue where I need to fetch each conversation related to each ticket. I can do this by calling each ticket using this template: '&lt;A href="https://domain.freshdesk.com/api/v2/tickets/[ticket" target="_blank"&gt;https://domain.freshdesk.com/api/v2/tickets/[ticket&lt;/A&gt; number]/conversations', where [ticket number] is updated each time the API has finished fetching all the conversations related to the ticket.&lt;/P&gt;
&lt;P&gt;Currently, I have this job:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jhammagisa_0-1716462499865.png" style="width: 672px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/166679i3368F1AF7509B68E/image-dimensions/672x136?v=v2" width="672" height="136" role="button" title="jhammagisa_0-1716462499865.png" alt="jhammagisa_0-1716462499865.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am not quite sure how to achieve my desired goal. Any advice would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for reference:&lt;/P&gt;
&lt;P&gt;My DBInput has this query: "&lt;SPAN class="s1"&gt;select&lt;/SPAN&gt; ticketID&amp;nbsp;&lt;SPAN class="s1"&gt;from&lt;/SPAN&gt; dw_ticket limit &lt;SPAN class="s2"&gt;1&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;tJava_2 has this condition:&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;/SPAN&gt; number_of_records=((Integer)globalMap.get(&lt;SPAN class="s2"&gt;"tLogRow_1_NB_LINE"&lt;/SPAN&gt;));&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt;(number_of_records == 100){&lt;/P&gt;
&lt;P class="p1"&gt;context.pageNum = context.pageNum + 1;&lt;/P&gt;
&lt;P class="p1"&gt;} &lt;SPAN class="s1"&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt; (number_of_records &amp;lt;= 100 &amp;amp;&amp;amp; number_of_records != 0) {&lt;/P&gt;
&lt;P class="p1"&gt;context.condition = &lt;SPAN class="s1"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p3"&gt;&lt;SPAN class="s3"&gt;} &lt;/SPAN&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;&lt;SPAN class="s3"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;context.condition = &lt;SPAN class="s1"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class="p1"&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 11:13:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2455639#M140678</guid>
      <dc:creator>jhammagisa</dc:creator>
      <dc:date>2024-05-23T11:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2455992#M140682</link>
      <description>&lt;P&gt;where's the tDBInput component in your job?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;My DBInput has this query: "&lt;SPAN class="s1"&gt;select&lt;/SPAN&gt;&amp;nbsp;ticketID&amp;nbsp;&lt;SPAN class="s1"&gt;from&lt;/SPAN&gt;&amp;nbsp;dw_ticket limit&amp;nbsp;&lt;SPAN class="s2"&gt;1&lt;/SPAN&gt;"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;=&amp;gt;Only query 1 ticketID? but you want to iterate all ticket ids one by one, and change the ticket id in the URL each time.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 08:39:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2455992#M140682</guid>
      <dc:creator>Shicong_Hong</dc:creator>
      <dc:date>2024-05-24T08:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2456382#M140686</link>
      <description>&lt;P&gt;Hi Shicong,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got my loop working already. Thank you for all your help.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is what my job looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jhammagisa_0-1716756459594.png" style="width: 696px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/166856i8D6D1BFA4F571968/image-dimensions/696x141?v=v2" width="696" height="141" role="button" title="jhammagisa_0-1716756459594.png" alt="jhammagisa_0-1716756459594.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 May 2024 20:48:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2456382#M140686</guid>
      <dc:creator>jhammagisa</dc:creator>
      <dc:date>2024-05-26T20:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop a tRestClient to fetch all data</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2456410#M140687</link>
      <description>&lt;P&gt;Great! Glad to be of help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 03:12:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-loop-a-tRestClient-to-fetch-all-data/m-p/2456410#M140687</guid>
      <dc:creator>Shicong_Hong</dc:creator>
      <dc:date>2024-05-27T03:12:45Z</dc:date>
    </item>
  </channel>
</rss>

