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.

·2 min read·View Oracle Docs

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 NameTypeDescription
ServerRequest.bodystring (read-only)Contains the body of the server request.
ServerRequest.filesObject (read-only)Provides access to any files sent with the request.
ServerRequest.headersObject (read-only)Contains the headers sent with the request.
ServerRequest.clientIpAddressstring (read-only)The IP address of the client making the request.
ServerRequest.methodhttp.MethodThe HTTP method used for the request (e.g., GET, POST).
ServerRequest.parametersObject (read-only)Contains the request parameters sent.
ServerRequest.urlstring (read-only)The URL of the server request.
ServerRequest.getLineCount(options)numberReturns the number of lines in a sublist.
ServerRequest.getSublistValue(options)stringRetrieves 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, and parameters for efficient request handling.
  • Its methods allow developers to access specific request details, improving error handling and data management capabilities.

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

Frequently Asked Questions (4)

What are the key properties of the ServerRequest object in SuiteScript 2.x?
The key properties of the ServerRequest object include 'body', 'files', 'headers', 'clientIpAddress', 'method', 'parameters', and 'url', all of which are read-only.
Can I modify the properties of the ServerRequest object?
No, the properties of the ServerRequest object are read-only, allowing only retrieval of data, not modification.
How can I retrieve the number of lines in a sublist using the ServerRequest object?
You can retrieve the number of lines in a sublist by using the 'getLineCount(options)' method of the ServerRequest object.
What should developers be cautious of when using the ServerRequest object?
Developers should always check for the presence of expected properties before using them to avoid runtime errors.
Source: ServerRequest Object Members 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 →