ServerRequest Object Members in SuiteScript 2.x API
The ServerRequest object in SuiteScript 2.x provides methods and properties for handling HTTP request data and metadata in NetSuite.
The ServerRequest object in SuiteScript 2.x is essential for handling HTTP requests in server scripts. It allows developers to access request data and metadata, providing a powerful way to interact with the NetSuite environment.
What is the ServerRequest Object?
The ServerRequest object facilitates the retrieval of data sent from the client as part of an HTTP request to server scripts, such as those written for Suitelets or RESTlets. This object is critical when you need to parse request bodies, headers, parameters, and more.
Key Members of the ServerRequest Object
Below are the properties and methods available for the ServerRequest object:
| Member Name | Type | Description |
|---|---|---|
ServerRequest.body | string (read-only) | Contains the body of the server request. |
ServerRequest.files | Object (read-only) | Provides access to any files sent with the request. |
ServerRequest.headers | Object (read-only) | Contains the headers sent with the request. |
ServerRequest.clientIpAddress | string (read-only) | The IP address of the client making the request. |
ServerRequest.method | http.Method | The HTTP method used for the request (e.g., GET, POST). |
ServerRequest.parameters | Object (read-only) | Contains the request parameters sent. |
ServerRequest.url | string (read-only) | The URL of the server request. |
ServerRequest.getLineCount(options) | number | Returns the number of lines in a sublist. |
ServerRequest.getSublistValue(options) | string | Retrieves the value of a specific sublist line item. |
Usage Considerations
- Always check for the presence of expected properties before using them to avoid runtime errors.
- The properties of the ServerRequest object are all read-only, meaning you can retrieve data but not modify it.
- Understanding the request's method and parameters is crucial for properly handling various HTTP request types.
Key Takeaways
- The ServerRequest object is vital for managing HTTP request data in NetSuite's SuiteScript API.
- It exposes useful properties like
body,headers, andparametersfor efficient request handling. - Its methods allow developers to access specific request details, improving error handling and data management capabilities.
Frequently Asked Questions (4)
What are the key properties of the ServerRequest object in SuiteScript 2.x?
Can I modify the properties of the ServerRequest object?
How can I retrieve the number of lines in a sublist using the ServerRequest object?
What should developers be cautious of when using the ServerRequest object?
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.
