Returning error messages using onBefore transform script via the REST API

Paul Ciarfella
Tera Guru

I'm evaluating how best to use the REST API to validate inbound requests.   For example, a client sends a POST request with a set of parameters to an Import Set staging table, where the parameters are validated in a transform map onBefore script.

So, I've created a dummy onBefore script that will return the following:

  error = true;

  error_message = "This is the error message";

  status_message = "This is the status message";

I expected that the REST response body would have the message fields returned exactly as above, but instead my messages are glommed with SN error text in the result block:

  "error_message": "onBefore script error. This is the error message; Target record not found",
  "status_message": "This is the status message;onBefore script error. This is the error message"


This is not what's documented in the wiki, at least what's documented for errors returned in SOAP responses.


Has anyone else seen this with REST and import set validation?

5 REPLIES 5

poornachander
Mega Expert

Hi, Did you ignore the transformation after the error ?!


try to put the following statement before or after setting the error variables.



ignore = true;




This stops the further transformation of the transform map and whatever the values you set on the variables will remain.


Yes, I also have ignore = true and the error messages are still the same.


The solution, at least for me, will be to create context-specific error message fields for the response.   And not use the status_message and error_message fields.


Community Alums
Not applicable

Hi,


Have you got the solution for the above requirement? Even our requirement is like not to get SN error text fields along with our error messages "error_message": " This is the error message; Target record not found" We dont want "Target record not found" message along with our error message.