Example of a Client Script that Calls a RESTlet
The following example shows how a client script can call a RESTlet. Because the client script is expected to have an active session, it uses a partial URL to call the RESTlet. That is, the URL does not have to include the RESTlet domain. You can find this partial URL in the URL field of the script deployment record for the RESTlet.
Note:
The partial URL in this example is a placeholder. Before using this script, replace this string with a valid value from your NetSuite account.
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define(['N/https'], function(https) {
return {
pageInit : function() {
var dataFromRestlet = https.get({
url: '/app/site/hosting/restlet.nl?script=200&deploy=1'
});
console.log(dataFromRestlet.body);
}
}
});
Related Topics
- SuiteScript 2.x RESTlet Script and Request Examples
- Example Hello World RESTlet
- Example of a RESTlet that Retrieves, Deletes, Creates, and Upserts a NetSuite Record
- Example of a RESTlet that Adds Multiple Records
- Example of a RESTlet that Manipulates Scheduled Script
- Example of a Suitelet that Calls a RESTlet
- Example of a Shell Script that Calls a RESTlet