N/http Module Members

Explore N/http module members for SuiteScript, enabling powerful HTTP requests and responses within client and server scripts.

·3 min read·View Oracle Docs

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

NameReturn Type / Value TypeSupported Script TypesDescription
http.ClientResponseObject (read-only)Server scriptsThe server's response to an HTTP client request, such as in http.get(options).
http.ServerRequestObject (read-only)Server scriptsContains HTTP request information sent to a server, typically used by Suitelet and RESTlet.
http.ServerResponseObjectServer scriptsRepresents the response from an HTTP server to an HTTP request, used to send responses back.

Methods

NameReturn Type / Value TypeSupported Script TypesDescription
http.delete(options)http.ClientResponse or http.ServerResponseClient and server scriptsSends an HTTP DELETE request and returns the response.
http.get(options)http.ClientResponse or http.ServerResponseClient and server scriptsSends an HTTP GET request and returns the response.
http.post(options)http.ClientResponse or http.ServerResponseClient and server scriptsSends an HTTP POST request and returns the response.
http.put(options)http.ClientResponse or http.ServerResponseClient and server scriptsSends an HTTP PUT request and returns the response.
http.request(options)http.ClientResponse or http.ServerResponseClient and server scriptsSends a general HTTP request and returns the response.

Enumerations

NameTypeSupported Script TypesDescription
http.CacheDurationenumServer scriptsHolds string values for supported cache durations.
http.MethodenumServer scriptsHolds string values for supported HTTP methods.
http.RedirectTypeenumServer scriptsHolds 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.

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

Frequently Asked Questions (4)

Does the N/http module support HTTPS connections?
No, the N/http module does not support HTTPS connections. For secure connections, the N/https module should be utilized instead.
Can the N/http module be used in both client and server scripts?
Yes, the N/http module methods such as get, post, put, delete, and request can be used in both client and server scripts.
What happens if I try to set blocked HTTP headers like 'Content-Length' or 'Host'?
Developers should avoid setting certain HTTP headers that are blocked to prevent security issues. Attempting to manually set these headers could lead to script errors or unexpected behavior.
Are there any specific script types where http.ClientResponse and http.ServerResponse objects can be used?
Yes, http.ClientResponse and http.ServerResponse objects are designed for server scripts, such as those executed by Suitelets and RESTlets.
Source: N/http Module 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 →