How to pass parameters to tRest component

One Star

How to pass parameters to tRest component

Hi,
I have a job (see screenshot) whereby I am submitting a REST request with an http Body. I would like to make it more dynamic whereby I would pass a parameter value to the job e.g. right now you see the following:
<creationDate>2015-06-18T16:12:15.290-07:00</creationDate>
instead I would like to do something like
<creationDate>myDateParameter</creationDate>
where myDateParameter would come from a list of dates. How would I change this job to achieve that? Also, how do I specify parameter values?
Thanks,
Doug
One Star

Re: How to pass parameters to tRest component

Hi,
I suppose you can have a tJavaFlex between the 2 tREST to change the body as you want or to set 1 or more global variables then, in the body you can use these variables:
- in tJavaFlex:
globalMap.put("creationDate", what_you_want);
- in tRest, field Body:
 "<overwriteFiles>true</overwriteFiles>
blablabla"+globalMap.get("creationDate")+"blablabla"
It should works.
Let me know.
Regards,
Fred
One Star

Re: How to pass parameters to tRest component

Hi,
I suppose you can have a tJavaFlex between the 2 tREST to change the body as you want or to set 1 or more global variables then, in the body you can use these variables:
- in tJavaFlex:
globalMap.put("creationDate", what_you_want);
- in tRest, field Body:
 "<overwriteFiles>true</overwriteFiles>
blablabla"+globalMap.get("creationDate")+"blablabla"
It should works.
Let me know.
Regards,
Fred

One Star

Re: How to pass parameters to tRest component

Hi,
Put a tLogRow before tRest1 to see what is sent to this component.
Also, you can execute your job using the debug mode or put some traces in the service called by tRest1.
Fred

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog