nlapiRequestRestlet(scriptId, deploymentId, urlParams, body, headers, httpMethod)
The content in this help topic pertains to SuiteScript 1.0. You can use this function in SuiteScript 1.0 scripts to call RESTlets written in SuiteScript 2.x code. For more information, see Using SuiteScript 2.x Scripts with SuiteScript 1.0 Scripts.
For information about SuiteScript 1.0, see SuiteScript 1.0 Documentation.
Description |
Sends an HTTPS request to a RESTlet and returns the response. Authentication headers are automatically added. The RESTlet runs with the same privileges as the calling script. If you use custom headers, make sure the names of these headers do not contain underscores. |
Returns |
|
Supported Script Types |
Server scripts |
Governance |
10 units |
Since |
2023.1 |
Parameters
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string | number |
required |
The internal ID or script ID of the script record. Specify internal ID as a number. Specify script ID as a string. |
2023.1 |
|
string |
required |
The script ID of the script deployment record. |
2023.1 |
|
Object<string, string> |
optional |
The parameters to be appended to the target URL as a query string. |
2023.1 |
|
string | Object<string, string> |
required, if |
The PUT/POST data. This parameter is ignored if |
2023.1 |
|
Object<string, string> |
optional |
The HTTPS headers. |
2023.1 |
|
string |
optional |
The HTTPS method (DELETE, GET, HEAD, POST, PUT). The default value is GET if |
2023.1 |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
— |
The |
|
— |
The authorization header is set. |
|
— |
The |
|
— |
The |
|
— |
The |
|
Missing a required argument: {param name} |
The |
|
— |
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
// Add additional code
...
var myRestletHeaders = {
myHeaderType: 'Test',
myHeaderStuff: 'This is my header',
myHeaderId: 7
};
var myUrlParameters = {
myFirstParameter: 'firstparam',
mySecondParameter: 'secondparam'
}
var myRestletResponse = nlapiRequestRestlet(
99,
'deploy1',
myUrlParameters,
'My Restlet body',
myRestletHeaders,
'GET'
);