https.requestRestlet(options)
Method Description |
Sends an HTTPS request to a RESTlet and returns the response. Authentication headers are automatically added. The RESTlet will run with the same privileges as the calling script. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
10 units |
Module |
|
Since |
2020.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string | Object |
required, if |
The PUT/POST data. This is ignored if the |
2020.2 |
|
string |
required |
The script ID of the script deployment record. |
2020.2 |
|
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. |
2020.2 |
|
Object |
required, if |
The HTTPS headers. Must contain at least a Content-Type header for |
2020.2 |
|
string |
optional |
The HTTPS method (DELETE, GET, HEAD, POST, PUT). The default value is GET if |
2020.2 |
|
Object |
optional |
The parameters to be appended to the target URL as a query string. |
2020.2 |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
— |
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
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 myRestletHeaders = {
myHeaderType: 'Test',
myHeaderStuff: 'This is my header',
myHeaderId: 7
};
var myUrlParameters = {
myFirstParameter: 'firstparam',
mySecondParameter: 'secondparam'
}
var myRestletResponse = https.requestRestlet({
body: 'My Restlet body',
deploymentId: 'deploy1',
headers: myRestletHeaders,
method: 'GET',
scriptId: 99,
urlParams: myUrlParameters
});
Add additional code