Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a job to extract data from an API and i'm using tREST component with a POST method.
These are the sample data from my API;
{ "data": [ { "name": "Lisa", "product": "product1", "unit": "unit1", },
{ "name": "Lisa", "product": "product1", "unit": "unit2", },
{ "name": "Lisa", "product": "product1", "unit": "unit3", }
] }
so currently what i'm doing is i have 3 tREST component in my job to call all the data, each component has different value in the HTTP Body as below;
tREST_1 : "{\"name\":\"Lisa\",\"product\":\"P1\",\"unit\":\"unit1\"}"
tREST_2: "{\"name\":\"Lisa\",\"product\":\"P1\",\"unit\":\"unit2\"}"
tREST_3: "{\"name\":\"Lisa\",\"product\":\"P1\",\"unit\":\"unit3\"}"
my question is, is it possible to loop the unit instead of defining one by one unit in 3 different tREST component? is there any way that i can only use 1 tREST component but able to extract data for all units?
please let me know if i need to explain in detail, thanks!
@SR2210 , you can use in tfixedflow have all three body and iterate by using tFlowtoIterate and use tjava component to print that body using a global variable and call the tRest component.
tfixedflowInput>>Main>>tFlowtoIterate>>Iterate>>tjava>>on component Ok>>tRest
Hi @manodwhb, thank you for your reply.
This is my first time using tfixedflowinput, can you help to explain which mode should i select here and how do i define all three body in the component? Also, how do i call that in tREST HTTP Body section?
really appreciate your help, thank you in advance
@SR2210 , use Inline content and check the below link to more about this component.
https://help.talend.com/reader/mjoDghHoMPI0yuyZ83a13Q/1UUiC6QzuUN4eQE4niDz4w
@SR2210 , your job design should be like below.
Hi @manodwhb,
i'm not sure if i'm doing this correctly. I managed to print the body in tJava component and link it to tREST as below;
is that how i should call the body in HTTP Body section in tREST? If yes, when i run the job i got a "204" error that means no content. I'm sure that the data is there as i have tried to define the body directly in tREST and the data is shown correctly.
Please assist, thank you
@SR2210 , print the body in java and check that is that correct on or not which you were passing. bypassing same body from postman is it working?
Hi @manodwhb, I've print the body and it's showing correct as what i defined in tfixedflowinput. i tried to use the same body in tREST and postman and it's working
@SR2210 ,then it could be a body that you need to pass in ", please check.