Skip to Content

GET error 400 Body in response SAP HCI / Rest POST Request (HTTP)

Apr 04, 2017 at 06:51 PM


avatar image
Former Member

Hi Experts,

We have an scenario where we're posting some data via a REST service (POST Operation), we're using a HTTP Adapter in SAP HCI, sometimes the fields are sent in a wrong way, and we got 400 error from the server due a validation payload, and it's correct, but We'd like to get the body response error from HTTP adapter and send it back to ECC.

Have anyone already done this?

Any Idea on how can We do that?


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

1 Answer

Best Answer
Sriprasad Shivaram Bhat Apr 05, 2017 at 04:56 AM

Hello Bruno.

I think you have to write script for response and then send it back to SAP ERP.

Below is the sample script given in SAP HELP


def Message processData(Message message) {

                // get a map of iflow properties
                def map = message.getProperties();

                // get an exception java class instance
                def ex = map.get("CamelExceptionCaught");
                if (ex!=null)

              // an http adapter throws an instance of org.apache.camel.component.ahc.AhcOperationFailedException
                    if (ex.getClass().getCanonicalName().equals("org.apache.camel.component.ahc.AhcOperationFailedException"))

                    // save the http error response as a message attachment 
                    def messageLog = messageLogFactory.getMessageLog(message);
                    messageLog.addAttachmentAsString("http.ResponseBody", ex.getResponseBody(), "text/plain");

                    // copy the http error response to an iflow's property

                    // copy the http error response to the message body

                    // copy the value of http error code (i.e. 500) to a property

                    // copy the value of http error text (i.e. "Internal Server Error") to a property


    return message;

You can form the XML in Script itself or you can have a content modifier after script the build XML using the properties set in the script.


Sriprasad Shivaram Bhat

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for sharing this, you made my day!

Former Member

Thanks for sharing, this also made my day.

You Rock!!