How to handle unergistered API Paramers?

Hi,

If I have an endpoint defined as below and pass an unregistered parameter, I am getting a 500 error back. Is there an event that fires when this occurs so that I can customize the response?

      [ROServiceMethod]
      [ROCustom('HttpApiPath','/v1/clients/{client_id_list}')]
      [ROCustom('HttpApiMethod','GET')]
      [ROCustom('HttpApiResult','200')]
function GetClientDetails(
         client_id_list : string;
         [ROCustom('HttpApiQueryParameter','1')]    client_name : string) : binary

If i pass the following URL, I will get an error response that I’d like to customize:

http://localhost:8099/v1/clients/123?foo=foo

response is:

<font size="7">Invalid Path</font>

Is there an event that is fired in this case so that I can customize the response?

Thanks

Hi,

You can set server.SendExceptionsAs500 to False.

In this case, you will receive exception message


if you like to customize this error, you can

procedure TMyHttpApiDispatcher.Process(aTransport: IROHTTPTransport; aRequest: IROHTTPRequest;
  aResponse: IROHTTPResponse; aRequestData, aResponseData: TStream);
begin
  try
     inherited;
  except
     // <<<<<< customize the response? i.e. aResponse/aResponseData
  end;
end;