RESTAPIResponse - setBody(Object body)

Set the body content to send in the web service response.

Table 1. Parameters
Name Type Description
body Object

The response body, as a JavaScript object.

The body content is automatically serialized to JSON or XML depending on the value of the Accept header passed in the request.

Table 2. Returns
Type Description
void

var body = {};
body.name = "incident";
body.number = "1234";
body.caller = {"id": "user1"};
response.setBody(body);
var bodyArray = [];
var body = {};
body.name = "incident";
body.number = "1234";
body.caller = {"id":"user1"};
bodyArray.push(body);
response.setBody(bodyArray);