[resolved] HELP: How do I get input row values to pass through REST Client

One Star

[resolved] HELP: How do I get input row values to pass through REST Client

Hi there. Simple question, I have a REST endpoint where I want part of the URL to be the unit id, and then pick that up to use as part of the "Loop XPATH query" in a tExtractXMLField component. Can anyone advise?

Accepted Solutions
Community Manager

Re: [resolved] HELP: How do I get input row values to pass through REST Client

Hi 
If I understand your request well, you need a tFlowToterate component to iterate item ID, so that it could be accessed on any other components. For example:
tMysqlInput--main--tFlowToterate-iterate-->tFixedFlowInput--main--tRestClient--main--tExtractXMLField--main--tLogRow
on tMysqlInput, read item ids from mysql table. 
on tFixedFlowInput, generate the current item id and pass it to tRestClient as input parameter. Define one column called item_id in the schema and then, in the single table, set the value of item_id column as (Integer)globalMap.get("item_id") 
on tExtractXMLField, set the loop xpath query as ""/bills/bill/"+(Integer)globaoMap.get("item_id")
It might not completely address your request, I hope it give you some hints.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
One Star

Re: [resolved] HELP: How do I get input row values to pass through REST Client

Hi there. Simple question, I have a REST endpoint where I want part of the URL to be the unit id, and then pick that up to use as part of the "Loop XPATH query" in a tExtractXMLField component. Can anyone advise?

Okay, lets qualify this. I'm taking in an item ID from the REST request as a REST path variable. The job then uses a REST client to get the data (as XML/POX) to be queried (the source has only geographic and date filtering, none by id). This is passed onto a tExtractXMLField where the requested item ID is needed to XPath the relevant data out. As soon as the flow hits the REST client, with the id field name in the input and response schema, it doesn't pass through.
Sorry, I'm a newbie, only been playing with this for a week and a half and would appreciate some help as I'm trying to justify using Talend instead of writing individual .NET WCF handlers, on the basis it will allow simpler extensibility in future.
Community Manager

Re: [resolved] HELP: How do I get input row values to pass through REST Client

Hi 
If I understand your request well, you need a tFlowToterate component to iterate item ID, so that it could be accessed on any other components. For example:
tMysqlInput--main--tFlowToterate-iterate-->tFixedFlowInput--main--tRestClient--main--tExtractXMLField--main--tLogRow
on tMysqlInput, read item ids from mysql table. 
on tFixedFlowInput, generate the current item id and pass it to tRestClient as input parameter. Define one column called item_id in the schema and then, in the single table, set the value of item_id column as (Integer)globalMap.get("item_id") 
on tExtractXMLField, set the loop xpath query as ""/bills/bill/"+(Integer)globaoMap.get("item_id")
It might not completely address your request, I hope it give you some hints.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] HELP: How do I get input row values to pass through REST Client

Hi 
If I understand your request well, you need a tFlowToterate component to iterate item ID, so that it could be accessed on any other components. For example:
tMysqlInput--main--tFlowToterate-iterate-->tFixedFlowInput--main--tRestClient--main--tExtractXMLField--main--tLogRow
on tMysqlInput, read item ids from mysql table. 
on tFixedFlowInput, generate the current item id and pass it to tRestClient as input parameter. Define one column called item_id in the schema and then, in the single table, set the value of item_id column as (Integer)globalMap.get("item_id") 
on tExtractXMLField, set the loop xpath query as ""/bills/bill/"+(Integer)globaoMap.get("item_id")
It might not completely address your request, I hope it give you some hints.
Best regards
Shong

I'll give it a go, but I don't think this addresses my problem. I have only 1 unique id coming in from the REST request that tExtractXMLField needs, but the tRESTClient that gets the XML to be queried seems to block that value getting through. My chain is:
tRESTRequest--main--tRESTClient--main--tExtractXMLField--main--tXMLMap--main--tRESTResponse
One Star

Re: [resolved] HELP: How do I get input row values to pass through REST Client

Well, it gave me inspiration. I used a tJavaRow after the tRESTRequest to pop the requested ID into globalMap (although it concerns me as to whether that would be global to a second request run at exactly the same time). Then, after retrieving the XML from the data-owning system and structuring it, I added a tRowFilter to only pull out the id in question.
Community Manager

Re: [resolved] HELP: How do I get input row values to pass through REST Client

Well, it gave me inspiration. I used a tJavaRow after the tRESTRequest to pop the requested ID into globalMap (although it concerns me as to whether that would be global to a second request run at exactly the same time). Then, after retrieving the XML from the data-owning system and structuring it, I added a tRowFilter to only pull out the id in question.

Great! Thanks for your feedback!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business