N/http Module
Use the N/http module to make HTTP calls from server or client scripts. For client scripts, this module also provides the ability to make cross-domain HTTP requests using NetSuite servers as proxies.
All HTTP content types are supported.
The N/http module does not accept the HTTPS protocol. Use the N/https Module for that purpose.
In This Help Topic
HTTP Header Information
HTTP headers can be used to pass additional information with an HTTP request or response. Each HTTP header consists of its case-insensitive name followed by a colon (:), then by its value (without line breaks). If you use custom headers, make sure the names of these headers do not contain underscores. For a general list of all HTTP headers, visit http://developer.mozilla.org/en-US/docs/Web/HTTP/Headers.
Some headers are not supported in NetSuite and are blocked. These are listed below as either general HTTP headers or Suitelet response headers.
General Blocked HTTP Headers
Be aware that certain headers cannot be set manually when using the N/http module methods. If a script attempts to set values for any of the following headers, the values are discarded. These headers are listed in the following table.
|
|
Suitelet Response HTTP Header Blocklist
In addition to the headers described in General Blocked HTTP Headers, certain headers cannot be set manually when interacting with the http.ServerResponse Objects sent by Suitelets. If a script attempts to set values for any of these headers, the system throws an SSS_INVALID_HEADER error. These headers are listed in the following table.
|
|
|
N/http Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object (read-only) |
Server scripts |
The response from the server to an HTTP client request (for example, http.get(options)). |
|
Object (read-only) |
Server scripts |
HTTP request information sent to an HTTP server. For example, a request sent to/received by a Suitelet or RESTlet. |
||
Object |
Server scripts |
The response from an HTTP server to an HTTP request. For example, a response from a Suitelet or RESTlet. |
||
Method |
Client and server scripts |
Sends an HTTP DELETE request and returns the response. |
||
Client and server scripts |
Sends an HTTP DELETE request asynchronously and returns the response. |
|||
Client and server scripts |
Sends an HTTP GET request and returns the response. |
|||
Client and server scripts |
Sends an HTTP GET request asynchronously and returns the response. |
|||
Client and server scripts |
Sends an HTTP POST request and returns the response. |
|||
Client and server scripts |
Sends an HTTP POST request asynchronously and returns the response. |
|||
Client and server scripts |
Sends an HTTP PUT request and returns the response. |
|||
Client and server scripts |
Sends an HTTP PUT request asynchronously and returns the response. |
|||
Client and server scripts |
Sends an HTTP request and returns the response. |
|||
Client and server scripts |
Sends an HTTP request asynchronously and returns the response. |
|||
Enum |
enum |
Server scripts |
Holds the string values for supported cache durations. Use this enum to set the value of the |
|
enum |
Server scripts |
Holds the string values for supported HTTP requests. Use this enum to set the value of |
||
enum |
Server scripts |
Holds the string values for supported NetSuite resources that you can redirect to. Use this enum to set the value of the |
ClientResponse Object Members
The following members are called on the http.ClientResponse Object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string (read-only) |
Server scripts |
The client response body. |
|
number (read-only) |
Server scripts |
The client response code. |
||
Object (read-only) |
Server scripts |
The client response headers. |
ServerRequest Object Members
The following members are called on the http.ServerRequest Object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
number |
Server scripts |
Returns the number of lines in a sublist. |
|
string |
Server scripts |
Returns the value of a sublist line item. |
||
Property |
string (read-only) |
Server scripts |
The server request body. |
|
Object (read-only) |
Server scripts |
The server request files. |
||
Object (read-only) |
Server scripts |
The server request headers. |
||
String (read-only) |
Server scripts |
The remote client IP address. |
||
Server scripts |
The server request HTTP method. |
|||
Object (read-only) |
Server scripts |
The server request parameters. |
||
string (read-only) |
Server scripts |
The server request URL. |
ServerResponse Object Members
The following members are called on the http.ServerResponse Object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
void |
Server scripts |
Adds a header to the response. |
|
string | string[] |
Server scripts |
Returns the value of a response header. |
||
void |
Server scripts |
Generates and renders a PDF directly to the response. |
||
void |
Server scripts |
Sets the redirect URL by resolving to a NetSuite resource. |
||
void |
Server scripts |
Sets CDN caching for a period of time. |
||
void |
Server scripts |
Sets the value of a response header. |
||
void |
Server scripts |
Writes information (text, xml, html) to the response. |
||
void |
Server scripts |
Writes a file to the response. |
||
void |
Server scripts |
Writes line information (text, xml, html) to the response. |
||
void |
Server scripts |
Generates a page. |
||
Property |
Object (read-only) |
Server scripts |
The server response headers. |