I have create my flows using APIKIT Router. The raml main flow+post://XX flow. Main flow and my POSt flow have Error handler components
MAIN FLOW:
<flow name="raml-main">
<http:listener .....">
<http:response statusCode="#[vars.httpStatus default 200]">
<http:body ><![CDATA[ ]]></http:body>
<http:headers><![CDATA[#[vars.outboundHeaders default {}]]]></http:headers>
</http:response>
<http:error-response statusCode="#[vars.httpStatus default 500]">
<http:body ><![CDATA[#[output application/json --- error.description]]]>
</http:body>
<http:headers><![CDATA[#[vars.outboundHeaders default {}]]]>
</http:headers>
</http:error-response>
</http:listener>
<apikit:router config-ref="raml-config" />
<error-handler>
<on-error-propagate type="APIKIT:BAD_REQUEST">
<logger level="INFO" doc:name="Logger" doc:id="aa51777e-c1c6-42d2-ba68-b51c45c9aeac" message="Im in MAIN FLOWWWW"/>
<ee:transform xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd" doc:id="4f00abf2-0b58-419e-8d9a-d3ef60e356ac">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{message: "BadMAIN request"}]]></ee:set-payload>
</ee:message>
<ee:variables>
<ee:set-variable variableName="httpStatus"><![CDATA[400]]></ee:set-variable>
</ee:variables>
</ee:transform>
</on-error-propagate>
POST FLOW
<flow name="post:\notifications:raml-config">
<json:validate-schema doc:name="Validate schema" doc:id="e447c719-60e2-4f34-aeb9-0b446a1a5eda" schema="schemas/event.json"/>
<choice>
.............................
</choice>
<error-handler >
<on-error-propagate type="JSON:SCHEMA_NOT_HONOURED" enableNotifications="true" logException="true">
<logger level="INFO" doc:name="Logger" doc:id="c818b292-5d89-48eb-aa8d-b7918daa8f0c" message="It is under post flow"/>
<ee:transform xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd" doc:id="e8fb927d-edb8-405a-b853-600b4788b719">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{message: "Bad Request"}]]></ee:set-payload>
</ee:message>
<ee:variables>
<ee:set-variable variableName="httpStatus"><![CDATA[400]]></ee:set-variable>
</ee:variables>
</ee:transform>
</on-error-propagate>
</error-handler>
</flow>
If I update payload under Transform processor at POST flow or RAML Main flow, it never gets reflected in the output. Say currently I get 400 bad request.
In the Transform component, if i change message, im not getting my modified message.
Why is that?
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{message: "Bad Request USER ERRROR.."}]]></ee:set-payload>
</ee:message>
RAML CONFIG
/notifications:
post:
headers:
Authorization:
required: false
type: string
responses:
'200':
description: OK
'400':
description: BAD REQUEST
'401':
description: NOT AUTHORIZED
400 means there is no such end point. It means your flow never gets invoked. There is another end point for which Mule is listening. Luckily Mule reports that url is wrong amd what kind of urls it is listening. Like this
INFO 2020-05-07 07:32:22,539 [http.listener.06 SelectorRunner] org.mule.service.http.impl.service.util.DefaultRequestMatcherRegistry: No listener found for request: (GET)/badurl
INFO 2020-05-07 07:32:22,539 [http.listener.06 SelectorRunner] org.mule.service.http.impl.service.util.DefaultRequestMatcherRegistry: Available listeners are: [([*])/console/*, ([*])/, ([*])/api/*]
Of course if you hit another server or another port or protocol then nothing knows about this request. But, since you have the answer - 400 - then you probably hit your server.
https://simpleflatservice.com/mule4/Recognize400Error.html
Default error handler and response could be also set in the http listener in the Responses - Error Response section