Skip to Content
avatar image
Former Member

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

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?


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    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

    Add comment
    10|10000 characters needed characters exceeded