Skip to Content

How to pass {http_result} from REST receiver adapter to REST sender adapter

Nov 01, 2017 at 12:05 PM


avatar image


We have a scenario where we are running REST-adapter to REST-adapter to expose a POST REST-service to a consumer system. I have a problem with the error handling where we want to respond with the error json payload from the receiver system as well as with the same HTTP Status code we get from the receiver system.

In the REST receiver adapter I am able to catch the error http status codes and set message content to {http_result}.

If I don’t do any error handling on REST Sender-side PI will respond with HTTP 200 OK and the json error payload from receiver system. However, if I want PI to also respond with the same HTTP status code as we get from the receiver system I’m unable to do that.

On the REST Sender side I try to catch the errors from receiver side by looking at the json payload:

“timestamp”: “2017-10-31T10:23:28.274+0000”,
“status”: 400,
“error”: “Bad Request”,
“exception”: “org.springframework.http.converter.HttpMessageNotReadableException”,
“message”: “JSON parse error: Unrecognized token ‘hej’: was expecting (‘true’, ‘false’ or ‘null’); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token ‘hej’: was expecting (‘true’, ‘false’ or ‘null’)\n at [Source:; line: 1, column: 7]”

But I am unable to also pass the http_result.:

The response to sender system will now be HTTP 400 but with a payload of “{http_result}”. Do you have any suggestions on how I can pass the http_result from REST receiver to REST sender adapter?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers