26
Views
6
Comments
How to capture specific API Error Messages (400 Bad Request)
Question
Application Type
Reactive
Service Studio Version
11.55.59 (Build 64640)
Platform Version
11.40.1 (Build 46624)

Hi everyone,

I’m currently migrating an integration from OutSystems 11 to ODC, and I’ve encountered a change in how REST API errors are handled.

The Scenario: In O11, when the API returns a 400 Bad Request, I can easily access the response body (JSON) which contains specific error messages (e.g., "Invalid Voucher Code" or "Voucher Expired"). This allows the front-end to display a user-friendly message based on the actual reason for the failure.

The Issue in ODC: In ODC, whenever the API returns a 400 error, the platform seems to intercept it and returns a generic message:

"Error Executing Test. Http Error Code: 400 - Bad Request. Title: Bad Request"

Because of this, I lose the specific error details coming from the API provider (Voucherify), making it difficult to inform the users what exactly went wrong.

Questions:

  1. Is there a way in ODC to prevent the platform from "masking" the 400 error body?

  2. Do I need to use the OnAfterResponse callback to manually capture and parse the error response before ODC throws the exception?

  3. Are there specific settings in the REST Integration or ODC portal to allow custom error messages to pass through?

Any insights or workarounds from those who have faced this in ODC would be greatly appreciated.

Thanks!



2026-06-20 17-43-43
Sherif El-Habibi
Champion

Hello,

I think this needs to be implemented manually within the OnAfterResponse callback.

You may refer to these links for further insights and assistance:

2022-09-27 05-23-26
Mohammad Shoeb

Hi Jesu,

you must use the OnAfterResponse callback to read the response before ODC converts it into a generic exception. 

Regards,

UserImage.jpg
jesu verso

good day sir sorry for super late repliy but im trying this approach may i ask how can i get the message bfore odc take that generic response? thanks!

2025-11-19 06-14-01
Miguel Verdasca
Champion

Hi Jesu,

In ODC, 4xx/5xx responses are treated as exceptions by default, which is why you’re seeing the generic "Error Executing…" message instead of the original response body.

To capture the actual 400 response body, you have two main options:

  1. Use OnAfterRespons: Implement the OnAfterResponse callback in your REST integration. There you can access:
    • Response.StatusCode
    • Response.Body
      • If StatusCode = 400, you can manually parse the JSON body and map it to your own structure before the platform throws the exception.
  2. Disable “Raise Exception on Error” (if available): In some cases, you can configure the REST method not to automatically raise an exception for non-2xx responses. This allows you to handle the response manually based on the status code.

There is no setting in ODC to completely "unmask" the error automatically, handling it explicitly via OnAfterResponse is the recommended approach.

That’s currently the cleanest workaround in ODC.

Hope this helps.

2024-10-05 13-30-20
Huy Hoang The

Hi,

You should handle errors in the "On After Response" section. More detailed information will be provided there.

UserImage.jpg
jesu verso

hello maybe im missing something been testing all in onafter response but still cant keep the message on the error message of api thanks! is there other way in after response? 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.