Ali Ben Messaoud
Ali Ben Messaoud

Reputation: 11920

tRestClient Talend with dynamic URL and paramters from DB returns null

I'm trying to use Talend from a REST web service and by passing parameters that come from a DB.

I̶ ̶a̶m̶ ̶t̶r̶y̶i̶n̶g̶ ̶t̶o̶ ̶l̶i̶n̶k̶ ̶t̶P̶o̶s̶g̶r̶e̶s̶q̶l̶I̶n̶p̶u̶t̶ ̶c̶o̶m̶p̶o̶n̶e̶n̶e̶t̶ ̶t̶o̶ ̶t̶h̶e̶ ̶t̶R̶e̶s̶t̶ ̶c̶o̶m̶p̶o̶n̶e̶n̶t̶ ̶a̶n̶d̶ ̶t̶o̶ ̶s̶e̶e̶ ̶h̶o̶w̶ ̶t̶o̶ ̶p̶a̶s̶s̶ ̶D̶B̶ ̶r̶o̶w̶s̶ ̶v̶a̶l̶u̶e̶ ̶i̶n̶ ̶t̶h̶e̶ ̶U̶R̶L̶,̶ ̶b̶u̶t̶ ̶i̶t̶s̶ ̶s̶e̶e̶m̶s̶ ̶t̶h̶a̶t̶ ̶t̶R̶E̶S̶T̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶a̶c̶c̶e̶p̶t̶ ̶t̶h̶i̶n̶g̶s̶ ̶l̶i̶k̶e̶ ̶t̶h̶i̶s̶.̶

T̶h̶i̶s̶ ̶i̶s̶ ̶w̶a̶h̶t̶ ̶I̶ ̶d̶i̶d̶ ̶u̶n̶t̶i̶l̶ ̶t̶h̶i̶s̶ ̶t̶i̶m̶e̶ ̶:̶

̶t̶P̶o̶s̶g̶r̶e̶s̶q̶l̶I̶n̶p̶u̶t̶ ̶x̶x̶x̶x̶x̶x̶ ̶t̶R̶E̶S̶T̶ ̶-̶-̶-̶>̶ ̶t̶E̶x̶t̶r̶a̶c̶t̶J̶S̶O̶N̶F̶i̶e̶l̶d̶s̶ ̶-̶-̶-̶>̶ ̶t̶M̶a̶p̶ ̶-̶-̶-̶>̶ ̶t̶P̶o̶s̶g̶r̶e̶s̶q̶l̶O̶u̶t̶p̶u̶t̶

I verified that the DB component returns data below:

enter image description here

I updated the job as this:

enter image description here

The Schema of tRESTClient is :

enter image description here

And I used globalMap to pass the values from the database:

The used URL is : "URL/search/"+ (String)globalMap.get("row1.hashtag")

But when I see the results, I found it used the "null" value to request the server.

Upvotes: 1

Views: 5953

Answers (1)

Ali Ben Messaoud
Ali Ben Messaoud

Reputation: 11920

All I needed is to use a tFlowToIterate component to iterate each row, so that we will able to access the input data extracted from DB and set a dynamic URL.

For example as I have before, the job must look like this :

BBin --main(row1)--> tFlowToITerate --iterate--> tREST ---> tExtractJSONFields ---> tMap ---> DBout

On tRest, we can set a dynamic URL like:

"SOME_URL/otherpath/"+(String)globalMap.get("row1.columnName")

Upvotes: 2

Related Questions