Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Parikhharshal
Creator III
Creator III

Rest API URL Null

Hi Talend experts
 
I have got below job which reads next API URL until it finds one also it iterates for different course_ids. I have tweaked the design a bit to run parallel execution(the idea is to use parallel execution option of iterate) to execute multiple calls at a time.
 
 
StoreCourseID:
//globalMap.put("canvas_id", row1.canvas_id);
globalMap.put("V_API_URL" + row1.canvas_id, " https://swinburneonline.instructure.com/api/v1/courses/"+ row1.canvas_id +"/analytics/student_summaries?per_page=100");
globalMap.put("V_LOOP"+ row1.canvas_id, true);
 
tLoop:
((Boolean) globalMap.get("V_LOOP"+ row1.canvas_id))
 
tRestClient:
 
((String) globalMap.get("V_API_URL" + row1.canvas_id))
 
GetNextUrl
System.out.println("Current URL IS: "+globalMap.get("V_API_URL"+ row1.canvas_id)); (prints correctly)
System.out.println("Rest URL"+ globalMap.get("tRESTClient_1_HEADERS")); (doesn't print and errors out to null)
java.util.List <STRING> strList&nbsp; = ((java.util.Map<STRING>&gt 0683p000009MA9p.pngglobalMap.get("tRESTClient_1_HEADERS")).get("Link");
&nbsp;
//System.out.println("Link Header URL is:"+ strList);
&nbsp;
java.util.List <STRING> new_list = java.util.Arrays.asList(strList.get(0).split(","));
int foundIndex = -1;
String next_url="";
&nbsp;
for(int i=0; i &lt; new_list.size(); i++)
&nbsp; {
&nbsp;&nbsp; &nbsp; if(new_list.get(i).indexOf("rel=\"next\"") != -1)
&nbsp;&nbsp; &nbsp; {
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Item Found...");
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; foundIndex = i;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; break;
&nbsp;&nbsp; &nbsp; }
&nbsp; }
&nbsp;
&nbsp; if (foundIndex != -1)
&nbsp; {
&nbsp; &nbsp; &nbsp; String[] found_item = new_list.get(foundIndex).split(";");&nbsp;
&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; next_url=found_item[0].substring(1,found_item[0].length() - 1);
&nbsp; &nbsp; &nbsp; System.out.println("Next URL is: " + next_url);
&nbsp; &nbsp; &nbsp; globalMap.put("next_url"+row1.canvas_id,next_url);&nbsp;
&nbsp; }
&nbsp; else
&nbsp; {
&nbsp; &nbsp; &nbsp; System.out.println("No Next URL found...");
&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;&nbsp; &nbsp; &nbsp; globalMap.put("V_LOOP"+ row1.canvas_id,false);
&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp; }
&nbsp;
SetNextURlToCurrUrl:
&nbsp;
if ((Boolean) globalMap.get("V_LOOP"+row1.canvas_id))
&nbsp;&nbsp; {
&nbsp;&nbsp; System.out.println("URL1 IS: "+globalMap.get("V_API_URL"));
&nbsp;&nbsp; globalMap.put("V_API_URL"+row1.canvas_id,globalMap.get("next_url"+row1.canvas_id));
&nbsp;&nbsp; System.out.println("URL IS: "+globalMap.get("V_API_URL"));
&nbsp;&nbsp; }
&nbsp;
So it makes calls multiple times as an example below:
https://abc.com/api/v1/courses/course_id1/analytics/student_summaries?per_page=100&amp;page=1
https://abc.com/api/v1/courses/course_id1/analytics/student_summaries?per_page=100&amp;page=2
https://abc.com/api/v1/courses/course_id1/analytics/student_summaries?per_page=100&amp;page=3
https://abc.com/api/v1/courses/course_id2/analytics/student_summaries?per_page=100&amp;page=1
https://abc.com/api/v1/courses/course_id3/analytics/student_summaries?per_page=100&amp;page=1
https://abc.com/api/v1/courses/course_id3/analytics/student_summaries?per_page=100&amp;page=2
https://abc.com/api/v1/courses/course_id3/analytics/student_summaries?per_page=100&amp;page=3
https://abc.com/api/v1/courses/course_id3/analytics/student_summaries?per_page=100&amp;page=4
&nbsp;
So in doing so I have run into problem where Rest URL is always getting NULL when I get it from GetNextURL (tjava) component. Not sure what's wrong. Any help is really appreciated!
&nbsp;
Thanks
Harshal.</STRING></STRING></STRING>
Labels (5)
1 Reply
Parikhharshal
Creator III
Creator III
Author

@rhall and @gr44: please help.