Six Stars

passing value to trest

hi ,

 

I have an issue in my job.

I have loaded some reports from an API using tRest component.

while I am extracting that API ,I am getting some data like id,name and key column and value below it.

so I have done the job like tRest component(POST method) --> tExtractJSONFields ----> finally loaded it to tfileoutputexcel

so in this I am getting ouput like

id,name,key

1,janu,Mnv674=

 

so the key which I got will be expired in every 8 hours.

so I want the key to be parsed to another trestcomponent (POST method) automatically.

I have done the job like

tREST component (POST method)  -->  tExtractJSONFields  ----> tfileoutputexcel --------------------- (on component ok) ------> tREST component -------> tExtractJSONFields ------------> tfileoutputjson

in the 2nd tREST component I will pass the key we are getting from the excel output into the http headers. 

 

I want the key to be automatically loaded to the second job.

 

could anyone of you please help in this.

 

regards,

harshi

 

 

 

 

  • Data Integration
  • ESB
2 ACCEPTED SOLUTIONS

Accepted Solutions
Six Stars sgv
Six Stars

Re: passing value to trest

Hi Injarapu,

 

I don't know if it's work, but you can try this.

After your tfileoutputexcel, you can use a tJavaFlex and in the principal code, write : globalMap.put("KEY", tFileoutputExcelRow.key)

Then  :   tJavaFlex --- Iterate --- tRest

And on your tRest, "http://www.blabla.com/"+(String)globalMap.get("KEY")

 

Good Luck ,

SGV

Six Stars sgv
Six Stars

Re: passing value to trest

in your http header value, you have to write : (String)globalMap.get("token")

If it doens't work as expected, show us the error message.

 

16 REPLIES
Six Stars sgv
Six Stars

Re: passing value to trest

Hi Injarapu,

 

I don't know if it's work, but you can try this.

After your tfileoutputexcel, you can use a tJavaFlex and in the principal code, write : globalMap.put("KEY", tFileoutputExcelRow.key)

Then  :   tJavaFlex --- Iterate --- tRest

And on your tRest, "http://www.blabla.com/"+(String)globalMap.get("KEY")

 

Good Luck ,

SGV

Community Manager

Re: passing value to trest

Hi
Store the key to context variables for used on the second calling. eg:'
tREST component (POST method) --> tExtractJSONFields ----> tfileoutputexcel -----main--tjavaRow---------------- (on component ok) ------> tREST component -------> tExtractJSONFields ------------> tfileoutputjson

on tjavarow:
context.key=input_row.key;

on the second tRest, you can use this context variable.

Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: passing value to trest

thank you but its not working sir

Six Stars

Re: passing value to trest

thank you sir its working
Six Stars sgv
Six Stars

Re: passing value to trest

You talk about which solution ? Can you send screen shot of your test please with settings ? I'm pretty sure that my solution works, or I don't understand the purpose of your job ...

Six Stars

Re: passing value to trest

sir,

sorry the solution you gave is not working.

context.key=input_row.key;
after passing it into tJavaRow then talend is throwing error as
key cannot be resolved or is not a field.

could you please tell me any other way
Six Stars

Re: passing value to trest

can anyone please help me in this
Six Stars sgv
Six Stars

Re: passing value to trest

Where are you blocking ?

I thought that your problem was solved.

Six Stars

Re: passing value to trest

sir ,

I want the output coming from tJavaflex or tjavarow and sending it to trest http header value.

I am not able to pass the variable to another trest component.

please help me in this
Six Stars sgv
Six Stars

Re: passing value to trest

Please send a screenshot of Job and settings, and show us what element cause you trouble. 
I don't understand where is the problem exactly, i need a visual explication.

Six Stars

Re: passing value to trest

sir,

my job is
tREST---------->tExtractJSONFields----------->tJavaRow------------->on component ok----------->tREST------------->tExtractJSONFields-------------->tfileoutputjson

so I have applied your logic in tJavaRow.
now this I have to pass this variable to second tREST component in http header value.
please look into this and give the solution
Six Stars sgv
Six Stars

Re: passing value to trest

What did you write in your tJavaRow ?

Six Stars

Re: passing value to trest

sorry ,
not tJavaRow.
In tJavaflex,
globalMap.put("token", row2.token);

this I have written.
from this tJavaflex I have connected to tREST.
I want this value to be in http header value in tREST
Six Stars sgv
Six Stars

Re: passing value to trest

in your http header value, you have to write : (String)globalMap.get("token")

If it doens't work as expected, show us the error message.

 

Six Stars

Re: passing value to trest

No sir. Its not working...
Six Stars

Re: passing value to trest

hi sgv,

thank you for your help.
I have passed globalMap.put("token", row2.token); in tJavaflex
---->main--->tFlowToIterate --> iterate--->tREST
In tREST I have written ((String)globalMap.get("row3.token")) in http header value (where I want this value I have posted)

regards,
harsitha