https.requestSuiteTalkRest(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Sends an HTTPS request to a SuiteTalk REST endpoint and returns the response. Authentication headers are automatically added.

Returns

https.ClientResponse

Supported Script Types

Server scripts

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

Governance

10 units

Module

N/https Module

Since

2020.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.body

string | Object

required, if options.method = POST or PUT

The PUT/POST data. This is ignored if the options.method parameter is not POST or PUT.

2020.2

options.url

string

required

The URL of a SuiteTalk REST endpoint. It may also contain query parameters.

The URL may be fully qualified, relative, or relative with the /services/rest/ prefix omitted.

2020.2

options.headers

Object

optional

The HTTPS headers.

2020.2

options.method

string

optional

The HTTPS method (DELETE, GET, HEAD, POST, PUT). The default value is GET if options.body is not specified, and POST if options.body is specified.

2020.2

Errors

Error Code

Message

Thrown If

SSS_AUTHORIZATION_HEADER_NOT_ALLOWED

The authorization header is set.

SSS_INVALID_HEADER

The options.headers parameter is in an invalid format or contains an invalid header.

SSS_INVALID_URL

If the value of the options.url parameter is invalid or does not reference a SuiteTalk REST endpoint.

SSS_MISSING_REQD_ARGUMENT

Missing a required argument: {param name}

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

SSS_REQUEST_LOOP_DETECTED

The script executes a recursive function that has exceeded the limit for the number of times a script can call itself using an HTTPS request.

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/https Module Script Samples.

          // Add additional code 
...
var mySuiteTalkRestHeaders = {
    myHeaderType: 'Test',
    myHeaderStuff: 'This is my header',
    myHeaderId: 7
};
var myRestSuiteTalkRestResponse = https.requestSuiteTalkRest({
    body: 'My SuiteTalk Rest body',
    headers: mySuiteTalkRestHeaders,
    method: GET,
    url: 'www.SuiteTalkRestUrl.com'
});
 Add additional code 

        

Related Topics

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

General Notices