Server Request Body in NetSuite SuiteScript 2.1
Understand the server request body type in SuiteScript 2.1, its properties, and how to use it effectively in scripts.
The server request body is a critical component of the N/http module in SuiteScript 2.1, providing read-only access to the HTTP request sent to a Suitelet or RESTlet. This property allows developers to retrieve the context of the HTTP request and process it within server scripts. Notably, this feature has been available since NetSuite version 2015.2, and it is important for the development of integrations and automated workflows.
What is the Server Request Body?
The server request body contains the data submitted by a client, such as form data in a POST request. As a read-only property, developers cannot modify the request body; attempting to do so will result in an error.
Property Details
- Property Description: The server request body.
- Type:
string(read-only) - Module: N/http Module
- Parent Object: http.ServerRequest
Error Handling
When working with the server request body, be aware of the following error code:
READ_ONLY_PROPERTY: This error is thrown if there is an attempt to edit this property, highlighting that the property cannot be modified.
Example Usage
Below is a code sample to demonstrate how to access the server request body. Please note that this is a syntax illustration, not a complete functional example:
1// Log the server request body2data = request.body;3log.debug({4 title: 'Server Request Body',5 details: data6});For comprehensive script examples, refer to the N/http Module Script Samples.
Related Considerations
While the N/http module facilitates HTTP requests, it does not support HTTPS protocol. For that purpose, developers should use the N/https Module. Additionally, certain HTTP headers are blocked within the module, preventing their manual setting in request headers.
Summary of Blocked Headers
Some headers that cannot be manipulated include:
- Connection
- Content-Length
- Host
- JSESSIONID
- Trailer
- Transfer-Encoding
- Upgrade
- Via
For effective development with the N/http module, understanding these limitations is essential.
Who This Affects
This information is pertinent for several roles in NetSuite:
- Administrators: Manage and control script deployments.
- Developers: Implement and debug server scripts leveraging the
N/httpmodule. - Integration Specialists: Develop integrations using Suitelets and RESTlets.
Key Takeaways:
- The server request body is read-only and important for handling HTTP request data.
- Attempting to modify the request body leads to an error (
READ_ONLY_PROPERTY). - Proper use of this feature enhances the development of web integrations in NetSuite scripts.
- Awareness of blocked HTTP headers is crucial when using the
N/httpmodule.
Frequently Asked Questions (4)
Can I modify the server request body in SuiteScript 2.1?
Which module should I use for HTTPS requests in NetSuite SuiteScript 2.1?
Are there any specific headers blocked when using the N/http module?
What type of data can the server request body in SuiteScript 2.1 contain?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
