restlet.Response

Object Description

An HTTP response of a RESTlet script.

This object is read-only.

Use restlet.createResponse(options) to create and return this object.

For a complete list of this object's properties, see Response Object Members.

Supported Script Types

RESTlet scripts

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

Module

N/scriptTypes/restlet Module

Methods and Properties

Response Object Members

Since

2024.1

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) {
        const htmlResponse = restlet.createResponse({ 
            content: '<h1>Hello World</h1>',
            contentType: 'text/html'
        });

        log.debug({
            title: 'Response Content-Type header: ',
            details: htmlResponse.contentType
        });

        return htmlResponse;
    };
    return { get: get };
}); 

          

Related Topics

General Notices