Five Stars

tRestClient GET

Hello,
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?



8 REPLIES
Nine 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).
Forteen Stars TRF
Forteen Stars

Re: tRestClient GET

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

TRF
Five 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)."


Nine 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.
Five 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.

Nine 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?

Five Stars

Re: tRestClient GET

Ok, 
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....

Nine 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)