Response.contentType

Property Description

The Content-Type header of the RESTlet HTTP response.

Type

string (read-only)

Module

N/scriptTypes/restlet Module

Parent Object

restlet.Response

Sibling Object Members

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