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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
SR2210
Contributor
Contributor

loop variables in tREST POST method

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\"}"

 

0683p000009MZk3.jpg

 

 

 

 

 

 

 

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!

 

 

Labels (5)
19 Replies
manodwhb
Champion II
Champion II

@SR2210 , if you have access to the API, you can check payload has passed from Talend in the backend.

 

SR2210
Contributor
Contributor
Author

@manodwhb it's not working..

manodwhb
Champion II
Champion II

@SR2210, Great.

SR2210
Contributor
Contributor
Author

@manodwhb sorry if you missed my message, i was saying it is not working. i think that the ((String)globalMap.get("body")) in my tREST fails to get the value from tJava. i have tried with "" and without still it's showing the same error Smiley Sad

manodwhb
Champion II
Champion II

@SR2210 , can you check in the backend to that API what json payload coming to API?

SR2210
Contributor
Contributor
Author

unfortunately i dont have access to the API
manodwhb
Champion II
Champion II

@SR2210, is that api can be tested with any bodayone? and what was payload you set in tfixedflow input?show that payload.

manodwhb
Champion II
Champion II

@SR2210 , when you pass below body it was working right in trest component? if yes you need to check that in tfixedflow are you passing the same way or not if yes you are passing you need to check the api url is the same are you using.

 

"{\"name\":\"Lisa\",\"product\":\"P1\",\"unit\":\"unit1\"}"

SR2210
Contributor
Contributor
Author

@manodwhb okay it's working now. what i did was remove all the \ in the body and remove tJava component. tFlowToIterate is linked directly to tREST.

 

in tfixedflowinput i define it like this;

{"name":"Lisa","product":"P1","unit":"unit1"} instead of "{\"name\":\"Lisa\",\"product\":\"P1\",\"unit\":\"unit1\"}"

 


@manodwhb wrote:

@SR2210 , when you pass below body it was working right in trest component? if yes you need to check that in tfixedflow are you passing the same way or not if yes you are passing you need to check the api url is the same are you using.

 

"{\"name\":\"Lisa\",\"product\":\"P1\",\"unit\":\"unit1\"}"


Thank you for your help 

manodwhb
Champion II
Champion II

@SR2210 , i have asked to use tjava to print the payload before passing to api to know that are you passing correctly or not.