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
- 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