tRestClient GET

Six Stars

tRestClient GET

I need some help with the use of t_rest_client Compionent.

I have in my sub_job a restfull Call (GET) that extract some records from my oracle db and then these records are sent to another db. I'm receiving an error when the GET retrieve an empty data set.

How can I handle this issue?

Ten Stars

Re: tRestClient GET

You should have an statusCode in the response.
200 = ok
300 / 301 = redirects
400 = error .(or other numbers)
Check the body which could have a json or xml with <success> or something similar.
Last check the response headers itelf (but that should be allready in statusCode).
Fifteen Stars TRF
Fifteen Stars

Re: tRestClient GET

Can you tell more about this error?
It's probably to null value in one of the tMap.

Six Stars

Re: tRestClient GET

Hi @Dijke,
I'm getting back a statusCode = 200, so it's like everything has gone well.

@TRF, the issue is that my data set from which I'm trying to get the data is empty at the moment.
If I execute the same SELECT in SQL i get back an empty dataset. But this is correct as the table from which I'm reading has no value.

I'm trying to figure it out how to manage the fact that the origin dataset is empty and that the reply that I receive from the REST call (i can see the message in the command line when I execute the job) is "Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document)."

Ten Stars

Re: tRestClient GET

@Margaz, the call is handled well status 200, except the server response cant return data, next the XML Doc parser cant process it which result in this error.
On the advance tab there's a checkbox : Convert response to DOM Document.
Use the String in stead of the body col and parse it later on to DOM.
Six Stars

Re: tRestClient GET

Sorry @Dijke I'm a newby.

Could you explain it in a simpler way?

Thank you veru much for your help.

Ten Stars

Re: tRestClient GET

tRESTClient component, go the advanced settings of this component.
There you will see a checbox : Convert response to DOM Document.
The response you receive from your server is processed by the tRESTClient component as DOM (XML) . It expects a response which is correctly formatted XML.
The server however send malformed XML because there's no data to return.
Try it with a table with data and see if it works... to be 100% sure and to isolate the problem.
Got it?

Six Stars

Re: tRestClient GET

now I get it. I have already tried to call the tRestClient (GET) that extract from the same table wiht data inside and this works. The problem is that this table is going to stay empty for some time, but during this period I need the job to run correctly also if the source table is empty. 

For now I solved partially the issue inserting a dummy record inside my table, but it would be nice to understand how to manage this call also with an empty source table....

Ten Stars

Re: tRestClient GET

Uncheck the DOM which I mentioned, it doesnt convert, it will give you the response as a string.
Next step is to test for this kind of error message.
Also cHeck with your DatabaseAdmin and maybe there's a Oracle setting which make it possible to return a xml reponse in stead of just the error string... (the error string is in XML format)


Join us at the Community Lounge.

Register Now


Talend named a Leader.

Get your copy


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 4

Pick up some tips and tricks with Context Variables


How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration


Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.