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.

·2 min read·View Oracle Docs

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:

suitescript
1// Log the server request body
2data = request.body;
3log.debug({
4 title: 'Server Request Body',
5 details: data
6});

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/http module.
  • 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/http module.

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

Frequently Asked Questions (4)

Can I modify the server request body in SuiteScript 2.1?
No, the server request body is a read-only property in the N/http module. Attempting to modify it will result in a READ_ONLY_PROPERTY error.
Which module should I use for HTTPS requests in NetSuite SuiteScript 2.1?
For HTTPS requests, you should use the N/https module as the N/http module does not support the HTTPS protocol.
Are there any specific headers blocked when using the N/http module?
Yes, some HTTP headers such as Connection, Content-Length, Host, and JSESSIONID are blocked and cannot be manipulated within the N/http module.
What type of data can the server request body in SuiteScript 2.1 contain?
The server request body typically contains data submitted by a client, such as form data included in a POST request.
Source: Syntax 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 →