Reputation: 1187
I have an internal Suitelet (at least I think I do... new to Suitelets, it is hosted in NetSuite). I try to use an internal url for my restlet, but every time I do, I get an error that I need a fully qualified URL for an http call. If I use the external URL, it works, but only if I pass my credentials in the header.
Is there any way to grab the user's credentials? Or to actually use the internal url and just keep everything inside with the current user's roles? The restlet creates records, and I'd rather that the owner be the user that is performing the action rather than me.
Thanks!
Upvotes: 1
Views: 3311
Reputation: 575
When using Internal URL, Its better to use url.resolveScript
from URL Module
It returns an external or internal URL string to a script.
var output = url.resolveScript({
scriptId: 'custom_script',
deploymentId: 'custom_script_deployment',
returnExternalUrl: false
});
Use HTTPS request in HTTPS module to send request
For a RESTlet called from an external client, you can use OAuth or the NetSuite-specific method NLAuth in the HTTP Authorization header. OAuth uses token-based authentication (TBA) to access resources on behalf of a user, eliminating the need to share login credentials such as username and password. See Using OAuth in the Authorization Header.
NLAuth passes in NetSuite login credentials such as company ID, user name, password, and role. See Using NLAuth in the Authorization Header.
For a RESTlet called from a client hosted by the same NetSuite account that hosts the RESTlet, you do not need to pass authentication information in the HTTP request. A check for all valid NetSuite session cookies occurs, and this existing session is reused.
For more information see Authentication for RESTlets
Upvotes: 3