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

General Notices