TIP: Error handling in WSO2 ESB APIs when the requested API resource does not match with the given URL template or pattern
When you send a HTTP request to an API in WSO2 ESB , if the requested API resource URL does not comply with the API resource definition, ESB returns HTTP 202 accepted response to the user. Due to this behavior, the client is unable to distinguish if they have made an error. We can use the following procedure to return a fault to the client in case of non-matching API resource is requested by client. Step 1: Suppose, we have an API similar to the following. Note that, the target web service is a JAXRS web application (jaxrs_basic) which is included in WSO2 Application Server by default. <api xmlns="http://ws.apache.org/ns/synapse" name="jaxrs" context="/jaxrs"> <resource methods="GET" uri-template="/customers/{id}"> <inSequence> <send> <endpoint> <address uri="http://localhost:9764/jaxrs_basic/services/customers/customerservice"/> ...