restlet.createResponse(options)

Method Description

Creates a custom RESTlet HTTP response.

Returns

restlet.Response

Supported Script Types

RESTlet scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/scriptTypes/restlet Module

Sibling Module Members

N/scriptTypes/restlet Module Members

Since

2024.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.content

string

required

The content of the response.

options.contentType

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

SSS_MISSING_REQD_ARGUMENT

{method name}: Missing a required argument: {param name}

A required parameter is missing.

SSS_INVALID_TYPE_ARG

You have entered an invalid type argument: {param name}

A parameter has an invalid type.

Syntax

Important:

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 };
}); 

          

Related Topics

General Notices