• : 1-877-596-8218
  • : sales@aecc.ca
# # #

RESTLet in NetSuite Part 1

In NetSuite System, there are two ways to set communications with external systems. For example, someone want build their own application to update records inside the Netsuite, or some other ERP/CRM systems want synchronizing with NetSuite, to update, import, or export records.
NetSuite provides two ways to achieve this. The SuiteTalk platform and the RESTLet.
In this article, we will only focus on the RestLet.
There are 4 supported HTTP methods for RestLet in NetSuite, GET, POST, PUT, and DELETE.
Let’s start this by creating a simple GET RestLet to get all items in NetSuite.

function getItems(datain) {
	var filters = [];
	var columns = [];
	filters[0] = new nlobjSearchFilter('inactive', null, 'is', false);
	columns[0] = new nlobjSearchColumn('internalid');
	columns[1] = new nlobjSearchColumn('itemid');
	columns[2] = new nlobjSearchColumn('class');
	columns[3] = new nlobjSearchColumn('description');
	columns[4] = new nlobjSearchColumn('location');
	try {
		var results = savedSearch('item', filters, columns);
	} catch (e) {
		nlapiLogExecution('debug', 'error', e.toString());
	var arrayOfItems = [];
	if (!isEmpty(results)) {
		for (var i in results ) {
			var itemObj = {
				"internalid" : results[i].getValue('internalid'),
				"itemID" : results[i].getValue('itemid'),
				"description" : results[i].getValue('description'),
				"productLine" : results[i].getText('class'),
				"location" : results[i].getText('location') ,
	return arrayOfItems;

In this restLet Script, we first search for all active items in the system, and then return each item info in an array of objects.

Then, we deployed this restLet into system, the scripting part is done.

The NetSuite system will provide an URI for this RestLet when it is deployed into the system.

Now let’s use this URI to make our first GET call.
The first step is to choose an Authentication for our RESTlet, there are different ways we can implement it. We can use the NLAuth method to pass credentials (login email, password, roles) in the header when calling the API, or use an OAuth token-based authentication (TBA) to get access. Here let’s use the NLAuth Method, the header is:

Authorization:NLAuth nlauth_account=Your Account, nlauth_email=Your Email, nlauth_signature=Your Password, nlauth_role=Your Role ID

For GET Request, if you want to pass in some values into the RestLet, you can add them as the URI parameters just like the script ID and deployment ID in the URI.

The Content-Type can be Text Or Json format. By default, netSuite will use plain Text format if no type specific in the header.