http.request(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Sends an HTTP request.

Important:

If negotiating a connection to the destination server exceeds 5 seconds, a connection timeout occurs. If transferring a payload to the server exceeds 45 seconds, a request timeout occurs.

Returns

http.ClientResponse or http.ServerResponse

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

10 units

Module

N/http Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.method

enum

required

The HTTP request method. Set using http.Method.

Note:

If the method is DELETE, this body data is ignored.

2015.2

options.url

string

required

The HTTP URL being requested

2015.2

options.body

string | Object

optional

The POST data if the method is POST. The PUT data if the method is P UT.

options.headers

Object

optional

The HTTP headers.

For more information, see HTTP Header Information.

2015.2

Errors

Error Code

Message

Thrown If

SSS_INVALID_HOST_CERT

An untrusted, unsupported, or invalid certificate was found for this host.

The client and server could not negotiate the desired level of security. The connection is no longer usable.

You may also receive this error if the domain name in the options.url parameter is spelled incorrectly or does not use valid syntax. Verify that the domain name:

  • Has 63 or fewer characters

  • Contains alphanumeric characters (a-z, A-Z, 0-9) or hyphens

  • Starts with a letter

  • Ends with a letter or digit

SSS_INVALID_URL

The URL must be a fully qualified HTTP/HTTPS URL.

An invalid URL is specified in the options.url parameter.

SSS_MISSING_REQD_ARGUMENT

Missing a required argument: {param name}

The options.method or options.url parameter is not specified.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/http Module Script Samples.

          // Add additional code 
...
var headerObj = {
    name: 'Accept-Language',
    value: 'en-us'
};
var response = http.request({
    method: http.Method.GET,
    url: 'http://www.google.com',
    body: 'My REQUEST Data',
    headers: headerObj
});
...
// Add additional code 

        

Related Topics

N/http Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices