restlet.createResponse(options)
Method Description |
Creates a custom HTTP response for a RESTlet. |
Returns |
|
Supported Script Types |
RESTlet scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Sibling Module Members |
|
Since |
2024.1 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
required |
The content of the response. |
|
string |
required |
The Content-Type header of the response. This value overrides the default Content-Type header, which is the same as the Content-Type header of the RESTlet HTTP request. |
Errors
Error Code |
Error Message |
Thrown If |
---|---|---|
|
{method name}: Missing a required argument: {param name} |
A required parameter is missing. |
|
You have entered an invalid type argument: {param name} |
A parameter has an invalid type. |
Syntax
The following code sample shows a basic implementation for this member. For a complete script example, see N/scriptTypes/restlet Module Script Sample.
/**
* @NApiVersion 2.1
* @NScriptType RESTlet
*/
define(['N/scriptTypes/restlet', 'N/query'],
function(restlet, query) {
const get = function (requestParams) {
return restlet.createResponse({
content: '<h1>Hello World</h1>',
contentType: 'text/html'
});
};
return { get: get };
});