Script: Class dw.system.RESTSuccessResponse
Class RESTSuccessResponse
- Object
- dw.system.RESTSuccessResponse
This class represents a REST success response that is compliant with the RFC standards. It can only be instantiated using the createSuccess
methods in RESTResponseMgr.
Here is an example:var body = {"hello": "world"} var success = RESTResponseMgr.createSuccess(body); success.render();
The above script would result in an HTTP response with status code 200 and the following body:{ "hello": "world" }
Constructor Summary
This class does not have a constructor, so you cannot create it directly.
Method Summary
render() : void
Sends the RESTSuccessResponse object as an HTTP response to the client.
Methods inherited from class Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Method Detail
render
render() : void
Sends the RESTSuccessResponse object as an HTTP response to the client. This sets the "Content-Type" header to "application/json" and expects the body to be a valid JavaScript JSON object.
Throws:
IllegalStateException - If the RESTSuccessResponse object is already rendered.
Exception - If there is an error while serializing the body.