How to display business rule error message in API call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 06:25 AM
I created a business rule to validate an email address. In the business rule code, if it is a bad email address, I call "gs.addErrorMessage()" with a useful message. When testing via a form, it works fine and I see the message. When I test via a REST API call however, I don't get my nice error message, the JSON returned has a more cryptic error message:
{
"error": {
"message": "Operation Failed",
"detail": "Operation against file 'x_xxxxxxxxx' was aborted by Business Rule 'Email Address Syntax Validate^62bfa7314f0332002bd6c3818110c776'. Business Rule Stack:Email Address Syntax Validate"
},
"status": "failure"
}
My question is: how can I set the error message to be returned in the JSON?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 07:29 AM
In order to return custom responses, you would have to write your own scripted REST API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 07:31 AM
Display Buysiness rule will work only on Form load. REST based connection will never reach to the form. I suggest you to embade the Business rule code as a response to web service response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2019 08:28 AM
Did you find any workaround for this? If so, please do let me know. Facing kind of similar issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2021 06:31 AM
Hi msimpson
Could you please let me know how you get this error object as API response?
In my case the response is empty. Is there any specific headers or any additional things I need to include in the BR or APIscript? Also could you share a code snippet if possible.
Thanks