Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Sending scripted REST API errors

Log in to subscribe to topics and get notified when content changes.

Sending scripted REST API errors

Scripted REST APIs provide multiple ways to send an error in a response to a requesting client.

The Script field on the Scripted REST Resource form provides a process function template.

You can send an error response by returning an error object, or using the processfunction response parameter. Either option returns the same error to the requesting client.

Returning an error

You can send an error by returning an error object.

(function process(request, response) { 
 // request is bad
 return new sn_ws_err.BadRequestError(‘My error message’);

Setting a response error

You can send an error by calling the setError function on the response parameter.

(function run(request, response) { 
 // request is bad
 responseBuilder.setError(new sn_ws_err.BadRequestError()); //Constructor parameter is optional