How to catch the message body after an http error?

One Star

How to catch the message body after an http error?

Hello everydody,
I send a message in a query.

But if the http response code isn't 200, I want to send my original message in a log (a log in my example but in a queue in my route).
In the cSetHeader, I get the body with the simple expression: "${Body}".

In the cHttp, I added the parameter throwExceptionOnFailure=false to retrieve the error.

After sending in http method, if the http return code isn't 200, I replace the body with cSetBody ("${headers.Body}").

My problem is when I get the message before the cHttp, I have an http error 400 (Bad Request) while this is a http 404 error.
Do you have an idea to resolve this problem ?

Thank you in advance.

Krokodile.
Moderator

Re: How to catch the message body after an http error?

Hi,
Could you please indicate on which build version you got this issue?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read