Hello Experts,
This is what I am trying to do.
I will call HTTPS from Postman, and the integration flow itself will show failure, which is my intention.
At the point when I call from Postman, the body of message only shows "An internal server error occured: The MPL ID of the failed message is : ......." and returned 500 internal server error as error code.
However, what I expect is that after calling from Postman, the body of message can show the details of error, just like what can be observed in SAP CPI.
Plus, I hope that I can change the error code as well. Now it is 500 but is it possible to change it?
I am aware that this should be done by some groovy script. Does anyone know how to achieve this?
Thank you.
Request clarification before answering.
Hi ,
// Retrieve the exception and MPL ID (if available)
def exceptionMessage = exception.getMessage()
def mplId = message.getHeader("MPL_ID")
// Prepare the custom error message
def errorMessage = "An internal server error occurred: MPL ID: ${mplId}, Error Message: ${exceptionMessage}"
// Set the custom error message in the response body
message.setBody(errorMessage)
// Set a custom HTTP status code (for example 400 instead of 500)
message.setHeader("HTTP_Response_Code", "400")
// Log the error (optional, for debugging)
messageLogFactory.getLogger().error("Custom Error: ${errorMessage}")
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.