Handle Exceptions caused by errors in the path of an exposed REST API

Handle Exceptions caused by errors in the path of an exposed REST API

  

Hey all,

Thanks for your support in advance :) 

I have the following issues:

We have a CRM systems that send messages to an REST API exposed by an Outsystems Application, when a customer is created or updated, to trigger specific processes based on this message.

The exposed REST API uses the customer id in the path to identify the customer ressource like "host/CRM_Integration/rest/Customer/v1/{CustomerId}".

But unfortunately our CRM allows special character in the Id field (Yes that's stupid but this is another discussion). That means sometimes we have stuff like white spaces or character like /\"( in the {CustomerId}.

In that case Outsystems is not forwarding the call to the API but responding with a HTML page with Status 500:

<html>
    <head>
        <META NAME="ROBOTS" CONTENT="NOINDEX"/>
        <title>Error</title>
    </head>
    <body bgcolor="#FFFFFF">There was an error processing your request. Please try again later...</body>
</html>

I can not find any mechanism to handle this error, could you help me?

Thanks!

Best

Oliver


Hi Oliver,

From what I can understand of your requirement, I think you could implement an "OnRequest" callback to fix those issues before they are processed by the platform. You can define what is the callback function to use for OnRequest when you define your REST service itself (on the module that provides the REST service).

Hi Jorge,

Thanks for the reply!

Unfortunately that is not helping. I should have mentioned that earlier but I tested, OnRequest of the API. OnBeginWebRequest and OnSessionStart of the Module and a Global Exception Handler. But nothing is called when this error occurs.