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