Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
I am stuck with a scenario where I use Talend rest API [ POST ] to run a different job and in response it gets 2 attributes in json run_id and number_in_job.
Now, I need to take the run_id number and invoke a API GET call to see the job result [ Success or Failure ] .
I know the URL for POST and GET.
How can I integrate API request [POST} and API [GET] to see the final output.
Thanks
Sathya
Hi Sathya
call the first API, use tExtractJSONFields to extract values from response JSON, store it to variable
use this variable in 2nd subjob to 2nd API call
Hi Vapukov,
Thanks for your response. Can you please explain me a bit as I am very new to ETL world.
I am trying as in the attached pic.
I a using tRest with POST to trigger a job and in response I am getting {"run_id":96,"number_in_job":20}
I need to use the "run_id":96 in another GET API to see the result.
GET API :- https://abc.net/api/2.0/job/runs/get?run_id=96
Thanks for helping
Sathya
Given the JSON you are receiving back, you need to configure your tExtractJsonFields component as in this image....
Your "JSON Field" value will be the output String column of your tRest component. If you configure the tExtractJsonFields component as above, it will output the values held in the JSON. Then you need to create your URL for your next API call using String concatenation.
@thinksathya wrote:
Hi Vapukov,
Thanks for your response. Can you please explain me a bit as I am very new to ETL world.
I am trying as in the attached pic.
I a using tRest with POST to trigger a job and in response I am getting {"run_id":96,"number_in_job":20}
I need to use the "run_id":96 in another GET API to see the result.
GET API :- https://abc.net/api/2.0/job/runs/get?run_id=96
Thanks for helping
Sathya
as showing by @rhall
first, you need to extract JSON
then you could use this column value in next component
Sorry @vapukov, I wasn't meaning to steal your thunder. I thought you might be asleep now 🙂
this is global resource - "The early bird catches the worm" 🙂
you need to use different connections between components
Iterate in your case does not transfer the value but do the loop only
and in 2nd tRESTClient, you need variable stored by iFlowToIterate, by default, it will be
(String)globalMap.get("row2.run_id")
row2 - it is name of input connection line for tFlowToIterate,
tJavaFlex - do nothing, empty