HTTP Method Syntax in SuiteScript N/http Module
Understand the syntax for HTTP methods in SuiteScript's N/http module, essential for making HTTP calls.
The HTTP method is a crucial part of server request handling in SuiteScript's N/http module. This specifies the action to be performed when making HTTP requests, such as retrieving or sending data.
Property Description
- Property: The server request HTTP method.
- Type:
http.Method(read-only) - Module: N/http Module
- Parent Object:
http.ServerRequest
Read-Only Behavior
If you attempt to modify the method property, you will encounter the READ_ONLY_PROPERTY error, indicating that this property cannot be changed once set.
Supported HTTP Methods
The http.Method enumeration includes the following HTTP methods, each used to perform specific actions:
| Value | Description |
|---|---|
| DELETE | Used to remove resources. |
| GET | Retrieves data from a server. |
| HEAD | Fetches header information without the body. |
| PUT | Updates existing resources. |
| POST | Sends data to a server for processing. |
| PATCH | Applies partial modifications to a resource. |
Syntax Example
Here is a code example illustrating how to use the HTTP method within the http module, though this is not a full functional example:
1// Add additional code 2... 3log.debug({ 4 title: 'Server Request Method', 5 details: request.method 6}); 7... 8// Add additional codeFor complete script examples, refer to the N/http Module Script Samples.
General Notes on HTTP Headers
While working with HTTP requests, be mindful that certain HTTP headers cannot be modified when using the N/http module. These include headers such as Connection, Content-Length, and Host. Attempting to set these headers will result in their values being discarded. Understanding these limitations is crucial for effective script development in SuiteScript.
Frequently Asked Questions (4)
What HTTP methods are available in the N/http module?
Can the HTTP method property be modified during a request in SuiteScript?
What happens if you try to set certain HTTP headers using the N/http module?
Is there a way to see the HTTP method used in a request with the N/http module?
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.
