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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category