N/http Module Members
Explore N/http module members for SuiteScript, enabling powerful HTTP requests and responses within client and server scripts.
The N/http module is essential for making HTTP calls from both client and server-side scripts in NetSuite. It allows developers to handle various HTTP content types and facilitates cross-domain requests using NetSuite servers as proxies. Notably, the N/http module does not support the HTTPS protocol; for secure connections, the N/https module should be utilized instead.
Available N/http Module Members
The N/http module comprises several members categorized as objects, methods, and enumerations, enabling different aspects of HTTP handling in SuiteScript.
Objects
| Name | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|
| http.ClientResponse | Object (read-only) | Server scripts | The server's response to an HTTP client request, such as in http.get(options). |
| http.ServerRequest | Object (read-only) | Server scripts | Contains HTTP request information sent to a server, typically used by Suitelet and RESTlet. |
| http.ServerResponse | Object | Server scripts | Represents the response from an HTTP server to an HTTP request, used to send responses back. |
Methods
| Name | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|
| http.delete(options) | http.ClientResponse or http.ServerResponse | Client and server scripts | Sends an HTTP DELETE request and returns the response. |
| http.get(options) | http.ClientResponse or http.ServerResponse | Client and server scripts | Sends an HTTP GET request and returns the response. |
| http.post(options) | http.ClientResponse or http.ServerResponse | Client and server scripts | Sends an HTTP POST request and returns the response. |
| http.put(options) | http.ClientResponse or http.ServerResponse | Client and server scripts | Sends an HTTP PUT request and returns the response. |
| http.request(options) | http.ClientResponse or http.ServerResponse | Client and server scripts | Sends a general HTTP request and returns the response. |
Enumerations
| Name | Type | Supported Script Types | Description |
|---|---|---|---|
| http.CacheDuration | enum | Server scripts | Holds string values for supported cache durations. |
| http.Method | enum | Server scripts | Holds string values for supported HTTP methods. |
| http.RedirectType | enum | Server scripts | Holds string values for supported resources that can be redirected to. |
Additional Features
In addition to core functionalities, the N/http module provides extensive error handling and the ability to manipulate HTTP headers, which is crucial for robust script interactions.
Important Header Information
Certain HTTP headers are blocked from being manually set to prevent security issues. Developers should avoid trying to set these headers:
- Connection
- Content-Length
- Host
- JSESSIONID
- ...and others listed under the General Blocked and Suitelet Response HTTP Header Blocklists.
Understanding these members and best practices for using the N/http module effectively is vital for any SuiteScript developer aiming to implement HTTP operations within NetSuite seamlessly.
Who This Affects
- Developers: Those utilizing SuiteScript for advanced integrations.
- Administrators: Individuals managing custom scripts and functionalities in NetSuite.
Key Takeaways
- The N/http module provides tools for making HTTP requests and handling responses in SuiteScript.
- Certain headers are blocked to maintain security and data integrity.
- For secure HTTPS requests, developers must use the N/https module instead.
Frequently Asked Questions (4)
Does the N/http module support HTTPS connections?
Can the N/http module be used in both client and server scripts?
What happens if I try to set blocked HTTP headers like 'Content-Length' or 'Host'?
Are there any specific script types where http.ClientResponse and http.ServerResponse objects can be used?
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