How to get HTTP status code in Mule 4?

Finding HTTP status code for error or success responses in Mule 4 application

Using error.muleMessage.attributes.StatusCode we can get the HTTP status code from the target system after the input message is sent. Use the below syntax in the Logger component to find out the exact HTTP status code from any Mule 4 application. Since outbound and inbound properties were changed and replaced by attributes use the below-given syntax

# [error.muleMessage.attributes.StatusCode]

Here is a detailed list and description of HTTP status codes for all client, server related information

How to set the HTTP status code in Mule 4?

Create a variable like below
<set-variable value="502" doc:name="httpStatus" variableName="httpStatus" />

Post a Comment

2 Comments

  1. Hi,

    I am facing a problem where I have a routing flow that routes all the request to downstream layers and if error happens then not able to send the proper status code to the caller.
    How to resolve this? Everytime 200 is going

    ReplyDelete
  2. #attributes.statusCode (In Mule 4) This is the attribute you need to update accordingly

    ReplyDelete