How to display business rule error message in API call

msimpson
Kilo Contributor

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?

4 REPLIES 4

Chuck Tomasi
Tera Patron

In order to return custom responses, you would have to write your own scripted REST API.



Scripted REST APIs


K10
Kilo Guru

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


Arun Kumar P1
Kilo Contributor

Did you find any workaround for this? If so, please do let me know. Facing kind of similar issue. 

ShAn21
Tera Guru

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