ServerResponse.addHeader(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Adds a header to the response.

If the same header has already been set, this method adds another line for that header. For example:

                    {Vary: ['Accept-Language', 'Accept-Encoding']} 

                  

For more information, see HTTP Header Information.

Returns

void

Supported Script Types

Server scripts

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

Governance

None

Module

N/http Module

Parent Object

http.ServerResponse

Sibling Object Members

ServerResponse Object Members

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.name

string

required

The name of the header.

2015.2

options.value

string

required

The value used to set the header.

2015.2

Errors

Error Code

Message

Thrown If

SSS_INVALID_HEADER

One or more headers are not valid.

The header name or value is invalid.

SSS_MISSING_REQD_ARGUMENT

Missing a required argument: {param name}

The options.name or options.value parameter is not specified.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/http Module Script Samples.

          // Add additional code 
...
serverResponse.addHeader({
    name: 'Accept-Language',
    value: 'en-us',
});
...
// Add additional code 

        

Related Topics

http.ServerResponse
HTTP Header Information
N/http Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices