ServerRequest.headers

Property Description

This object represents a series of name:value pairs. Each pair represents a server request header name and its value.

Typically, this object encapsulates two iterations of each header name: one in lower case and another in title case. This behavior is designed so that you can use either lower case or title case when you reference a header. However, the existence of title-case iterations of header names is not guaranteed. For best results, refer to header names using all lower-case letters (and hyphens, when applicable). If you use custom headers, make sure the names of these headers do not contain underscores.

Important:

The server request headers and their values are subject to change. If you use these headers in your scripts, you are responsible for testing them to make sure that they contain the information you need. For example, when making an HTTP call to a Suitelet, some headers might be filtered out. Filtering can occur if the headers affect how NetSuite processes the request internally. These filtered headers are not available to the Suitelet, so you should test to see whether a header was filtered out. If so, use a different header instead.

For more information, see HTTPS Header Information.

Type

Object (read-only)

Supported Script Types

Server scripts

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

Module

N/https Module

Since

2015.2

Errors

Error Code

Thrown If

READ_ONLY_PROPERTY

You attempted to edit this property. This property is read-only.

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/https Module Script Samples.

          // Add additional code 
...
log.debug({
    title: 'Server Request Headers',
    details: request.headers
});
...
// Add additional code 

        

Code Samples

Note:

This script sample uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects

          /**
 *@NApiVersion 2.x
 *@NScriptType Suitelet
 */
 define([], function() {
    function onRequest(context) {        
        var headers = context.request.headers; // {"headers":{...,"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","Accept-Encoding":"gzip"}...}
        ...
        // Add additional code
        ... 
    }
 
    return {
        onRequest: onRequest
    };
}); 

        

Related Topics

General Notices