This documentation is for WSO2 API Manager 1.10.0 View documentation for the latest release.
Page Comparison - Change the Default Mediation Flow of API Requests (v.8 vs v.9) - API Manager 1.10.0 - WSO2 Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: DOCUMENTATION-3743

...

Info
titleTruobleshooting

Use the following sample sequence to handle faults, when an invalid JSON request is sent.

Code Block
titleIn sequence
<?xml version="1.0" encoding="UTF­8"?> 
<sequence xmlns="http://ws.apache.org/ns/synapse" 
	name="<insequence_name>" 
	onError="fault" > 
	<log level="full"> 
		<property name="MessageFlow" 
		value="­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­--------In sequence of the message flow­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­-------"/> 
	</log> 
</sequence> 
Code Block
titleMain Fault Sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="fault"  onError="faultSeq" > 
	<log level="custom">
		<property name="STATUS:" value="­­­­­­­­­­­­­­­­fault invoked­­­­­­­­­­­­­­­­­­­­­­­" /> 
		<property name="STATUS" value="Executing default 'fault' sequence" />
		<property name="ERROR_CODE" expression="get­property('ERROR_CODE')" /> 
		<property name="ERROR_MESSAGE" expression="get­property('ERROR_MESSAGE')" />
	</log>
	<switch source="//fault/type........">
		<case regex="invalid......">................</case>
		<default>...............</default>
	</switch>
	<class name="org.wso2.carbon.apimgt.usage.publisher.APIMgtFaultHandler" /> 
	<property name="RESPONSE" value="true" />
	<header name="To" action="remove" />
	<property name="NO_ENTITY_BODY" scope="axis2" action="remove" />
	........................................................................................ 
	<property name="X­JWT­Assertion" scope="transport" action="remove" /> <sequence key="_cors_request_handler_" />
	<send /> 
</sequence>
Code Block
titleInvalid Payload Handling Error Sequence
<?xml version="1.0" encoding="UTF­8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse"  name="faultSeq" >
<class name="org.wso2.carbon.samples.FaultErrorMediator"></class>
<property description="" name="ContentType" scope="axis2" type="STRING" value="application/xml"/>
	<sequence key="fault"/> 
</sequence>


Add these error sequences using WSO2 Developer Studio, following the steps mentioned above.