Micho Micho - 24 days ago 22
Javascript Question

Failed NetSuite RESTlet authentication

I'm trying to develop in NetSuite a simple form portlet submitting to a RESTlet in the back end. Here's my form portlet:

function workManagerPortlet(portlet, column) {

portlet.setTitle('Portlet');

portlet.addField(....)
// INSERT HERE ALL THE FORM FIELDS

portlet.setSubmitButton(nlapiResolveURL('RESTLET', 'customscript_gw_ss_form_backend', 'customdeploy_wm_form_backend', true), 'Submit', '_hidden');
}


When I click on submit I can see in Chrome's developer console the status is 206 Partial Content, but the record I'm submitting is not being stored in the database and in the console there's no response for this request.

Therefore, I decided to investigate the connection to the RESTlet. My problem is that I cannot get past the RESTlet authentication. Here are my NLAuth headers:


User-Agent: SuiteScript-Call
Authorization: NLAuth
nlauth_account:
TSTDRV1291212
nlauth_email: $email
nlauth_signature: $password

nlauth_role: administrator
Content-Type: application/json


Obviously, replacing '$email' and '$password' for the corresponding values.

The 'nlauth_role' value is the role id in Netsuite.

I'm using Postman to test this and I always get a "401 Authorization Required" status and the following error.


{
"error":
{

"code": "USER_ERROR",

"message": "header is not NLAuth scheme [ NLAuth ]"
}
}


Any ideas about what I'm doing wrong?

Answer

nlauth values should be comma separated like this:

NLAuth nlauth_account: TSTDRV1291212, nlauth_email: $email, nlauth_signature: $password, nlauth_role: administrator`

One more thing, trying sending 3 instead of administrator. It's role id actually which is required by NetSuite.

Comments