Managing HTTPS Headers in SuiteScript for Integration

Manage HTTPS headers in SuiteScript effectively, covering blocked headers and default content types for smoother integrations.

·3 min read·View Oracle Docs

HTTP headers are essential components of web requests and responses, providing critical metadata about the transaction. In SuiteScript, understanding how these headers function, especially regarding integration, is crucial for developers. Here’s a comprehensive overview of HTTPS header information, default behaviors, and practices in the context of NetSuite integration.

What are HTTP Headers?

HTTP headers consist of a case-insensitive name followed by a colon and a value, providing additional information about the request or response. It’s important to note that when defining custom headers, underscores should be avoided in the names. For a comprehensive list of standard HTTP and HTTPS headers, you can refer to documentation like that from Mozilla.

Default Content-Type Headers

When using the https.post(options) method in SuiteScript, specifying a Content-Type header is optional. If omitted, NetSuite automatically assigns a default value depending on the nature of the request body:

Request Body TypeDefault Content-Type Header
Objectapplication/octet-stream
Uint8Arrayapplication/x-www-form-urlencoded; charset=UTF-8
Other typetext/xml; charset=UTF-8

Response Encoding

By default, the https.ServerResponse encodes text responses in UTF-8. If your application requires a different encoding for a file return, alternatives can be explored — see the related guides for more details.

Blocked HTTPS Headers

Not all headers can be set manually in SuiteScript, particularly within the N/https module methods. Attempting to set values for certain blocked headers results in discarded values. Here is a summary of the general HTTPS headers that are restricted:

Blocked Header Name
Connection
Content-Length
Host
JSESSIONID
Trailer
Transfer-Encoding
Upgrade
Via

Suitelet Response HTTPS Header Restrictions

In addition to the headers mentioned above, some headers are explicitly blocked when using the https.ServerResponse objects in Suitelets. If you attempt to set these headers, it will trigger an SSS_INVALID_HEADER error. The blocked headers for Suitelet responses include:

Blocked Suitelet Header Name
Allow
Content-Location
Content-MD5
Content-Range
Date
Location
Proxy-Authenticate
Public-Key-Pins
Public-Key-Pins-Report-Only
Retry-After
Server
Strict-Transport-Security
Upgrade-Insecure-Requests
Warning
WWW-Authenticate

Conclusion

Being aware of HTTPS header management is particularly important for developers working on integrations within NetSuite. By understanding both the default values and the limitations imposed by blocked headers, scripts can be designed more effectively to handle requests and responses within the NetSuite ecosystem.

Key Takeaways

  • HTTP headers provide essential metadata for requests and responses.
  • Default Content-Type values depend on the type of request body sent.
  • Certain headers are blocked from manual setting in SuiteScript.
  • Knowledge of blocked headers helps avoid runtime errors in applications.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

What happens if I omit the Content-Type header in a SuiteScript post request?
If you omit the Content-Type header in a SuiteScript post request, NetSuite will automatically assign a default value based on the request body type, such as 'application/octet-stream' for objects.
Are there any HTTPS headers that are blocked from being set in SuiteScript?
Yes, there are several HTTPS headers that are blocked from being set in SuiteScript, including Connection, Content-Length, and Host, among others. Attempting to set these headers results in discarded values.
What additional headers are blocked in Suitelet responses and can cause errors?
In Suitelet responses, additional blocked headers include Allow, Content-Location, and Content-Range. Setting these headers will trigger an 'SSS_INVALID_HEADER' error.
Can I use underscores in custom HTTP header names in SuiteScript?
No, it is advised to avoid using underscores in custom HTTP header names in SuiteScript to ensure proper functionality.
Source: HTTPS Header Information Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →