Search code examples
xmlhttprestoutputtalend

How to use the Talend tRest component output


I'm using the 'tRest' component to perform a HTTP Post. When that request succeeds, I receive information in XML format. How can I access that information in the next component? My next step is to convert that information in a CSV format. And if I want to save the information I get from the HTTP Post into a XML file, how can I do that?

Thanks.


Solution

  • tRest components allow you to make http calls to REST services (both GET and POST are supported) and retrieve the responses in a String field called 'body'. Then you can parse these XML responses using the tExtractXMLComponent which, as the name states, extracts one or more fields from the XML according to XQuery paths. It outputs to standard structured rows.

    This example job calls a public REST service and output to console both the parsed response and the raw XML body. Talend job using tRest

    And here's the above example properties for tExtractXMLField. Notice how each output column is mapped to a field of the response throught the use of XPath queries.

    enter image description here