tREST Retrieve the XML body of the response

One Star

tREST Retrieve the XML body of the response

Hello,
I'm using the tREST component with the PUT method (Talend v4.2.3). When I make a request on the RESTFul webservice, I should have a XML body in response (In addition to the status code and the message). Notice that the response has a XML body as well in case of error (code 400) that in case of success (code 200).
Currently, the row1.body and the row1.ERROR_MESSAGE are empty. Do you know how I can always retrieve them ?
My job has only :
tjava_1 --> tREST_1 --> tMap_1 --> tLogRow_1
tjava_1 : Initialize the contexts api_url and feed
tREST_1 :
url = context.api_url
Headers :
"Host" "xxx"
"Content-Type" "text/xml; charset=utf-8"
tMap_1 : row1.Body , row1.ERROR_CODE , ((String)globalMap.get("tREST_1_ERROR_MESSAGE"))

Thanks a lot for your help,
Carole
One Star

Re: tREST Retrieve the XML body of the response

Hi
I'm not sure whether i understand you.
What do you mean 'always retrieve them'?
You mean? When you get a '400 code', you still want to get the XML body?
400 code means that the request url or dns is wrong.
Best regards!
Pedro
One Star

Re: tREST Retrieve the XML body of the response

Hi Pedro,
Yes it is that. I still want to get the XML body when I get a '400 code'.
Thank you,
Carole
One Star

Re: tREST Retrieve the XML body of the response

Hi Pedro,
Yes it is that. I still want to get the XML body when I get a '400 code'.
Thank you,
Carole
One Star

Re: tREST Retrieve the XML body of the response

Hi Carole
When you get a '400 code', the value of body will be null, which can't be changed.
You may use tExtractXMLField to retrieve it.
Best regards!
Pedro
One Star

Re: tREST Retrieve the XML body of the response

Thanks for your answer.
I try with tExtractXMLField, but it doesn't work.
Regards,
Carole
One Star

Re: tREST Retrieve the XML body of the response

Hi,
I am trying to call a rest post service using  tRest component. The service takes JSON object as the input pojo. When I try to put the JSON object inside HTTP body field, it is giving error. Can anyone please tell me how can I call a rest service with JSON Post input?