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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
sbhadra
Contributor II
Contributor II

Get the data by making an API call in JSON format

Hi Team,

 

I need get some list of data from an api which is given to me. The api url is something like mentioned below

 

http://api.xyz.com/1/statuses/home_timeline.json?since_id=12345&max_id=54321&created=2020-01-09T00:00:00Z&created=2020-01-10T00:00:00Z)

 

Over here we have two dates 9th Jan and 10th Jan. Hence, I need all the the data of 9th Jan for entire 24 hrs in json format. What should be the talend job design. I had checked couple of talend community posts which suggests I need to use tRestClient however, I am not sure how to proceed further. Please suggest on the same

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

 

your job design will look like :

trestClient --ResponseOK--> tExtractJSONField --main--> tLogRow 

View solution in original post

8 Replies
root
Creator II
Creator II

You are on the right track. Can you share what you have coded so far and what is the error you are receiving? Thanks
Anonymous
Not applicable

Hi,

 

your job design will look like :

trestClient --ResponseOK--> tExtractJSONField --main--> tLogRow 

sbhadra
Contributor II
Contributor II
Author

Can you please provide an example. A job flow screenshot would be appreciating. Also the created date will be based on the current date created>=2019-01-09T00:00:00Z and created<2019-06-10T00:00:00Z where in date with < will be the current date and time, and >= will be the subtracted date based on data provided in context property file like 6 hrs , 12 hrs, 24 hrs etc.  

Anonymous
Not applicable

For testing, print the response to console to see if you are able to call the API has the response.
tRest--main--tLogRow

Next, you need to use a tExtractJsonField to extract data from the response.
tRest--main--tExtractJsonField--tLogRow

Let me know which step are you on now or any error do you have?

Regards
Shong
sbhadra
Contributor II
Contributor II
Author

Hi Team,

 

As per the instruction I am able to get the desired result however, I am facing another issue in the same. After I extract the json with the help of textractjsonfields component I am getting some ids (let say 1111, 2222 etc). I want to iterate through this ids and create a separate url which will be used to hit another api using tRestClient. The current flow is mentioned below

 

tRestCliet->tExtractJsonFields-> Getting the Ids over here and need those ids to build a url like mentioned below

https://api.xyz.com/1111/details.json

https://api.xyz.com/2222/details.json

 

Only the id value will change, hence I need to iterate through this ids to create individual urls which is  to be called individually to capture the response.

 

Please suggest any resolution for the same.

Anonymous
Not applicable

Hi,

 

If you only need the id sent from your first service, an example could be :

 

Talend schemaTalend schematsetglobalvar parameterstsetglobalvar parameterssecond api callsecond api call

 

filter your ids with tFilterColumns and delete the possibly duplicates with tUniqRow, then tFlowtoIterate permits to make a treatment id by id.

Write your id in a globalVar with tsetglobalVar and use it 'OnComponentOK' in your tRESTClient_2 as explained in the pictures.

 

Regards,

Pierre

sbhadra
Contributor II
Contributor II
Author

Thanks it worked for me.

sbhadra
Contributor II
Contributor II
Author

Hi Team,

 

If I want to use the same id to call another api to extract some data how to proceed in such a scenario. Like say 

 After textractJsonFields I want to have another api call with the id which is the current iteration value

https://api.xyz.com/details/1111/comments.json where 1111 is the id, which is the current iterated value using tflowToIterate component.