Example of a Client Script that Calls a RESTlet
Here’s an example of how a client script can call a RESTlet.Since the client script already has an active session, it uses a partial URL to call the RESTlet. That means you don’t need to include the RESTlet domain in the URL. You’ll find this partial URL in the URL field of the script deployment record for the RESTlet.
Note:
The partial URL in this example is just a placeholder—be sure to swap it for a valid value from your NetSuite account before using the script.
/**
* @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