Would anyone know of a way to determine the extern...
# suitetalkapi
s
Would anyone know of a way to determine the external URL of a Restlet without using SuiteScript N/URL? I see that you can combine the datacenter GET "https://rest.netsuite.com/rest/datacenterurls?account=" and possibly filling in the deployid and scriptid but wondering whether there's a standard way to do this
you dont actually need to use the internal id of the script and deployment
you can also use the scriptid of the script and deployment records for the script and deploy parameters
s
so it's a combination of: 1. get host via data center URL service using account id 2. append path /app/site/hosting/restlet.nl 3. append params script=[scriptid] deploy=[deployid] (how can these be determined programmatically?) I see suiteql REST could be one option or is it simpler?
b
the script id of a script deployment begins with
customdeploy
the script id of a script record begins with
customscript
the internal id of a script deployment or script record is a positive integer
either the internal id or the script id can be used as the value for the script or deploy query parameters
s
oh, wow.
super insight thanks
j
We have a set of services that interact with multiple Netsuite accounts. • Each netsuite tenant has a resetlet that returns all of the script deployments as Json • Our services have a list of netsuite script names (as that’s a field that we can control) At our service’s startup, we HTTP GET the only hard-coded restlet we have (the one to show all script deployments) We cache that data internally and line our script names up with the DeploymentId and ScriptId from the script deployment restlet.
s
Hey Joel, thanks for that. With this strategy you might even not need to use that one restlet to return all deployments (if it’s only being used to determine deploy ids of course)
You can just get the main host using the public data center endpoint, and fill in the Params with the custscript_** and custdeploy_** of the restlets you’re deploying in their accounts
j
For example, we have aura_fileC.js. This restlet is shared across 8-9 netsuite accounts. It might be scriptId 1 deployment 1 on one account, it might be scriptId 151 deployment 2- we don’t know. The only value we can control is the name so custscript_aura_filec is referenced in our codebase, then we have to ask the account what it’s scriptId and deploymentId is for each netsuite account. At runtime, we can compose the restlet uri with the scriptId and deploymentId.
s
Understood, but using the approach battk mentioned, you won't need to determine the internal ids for each tenant which could save you that additional restlet and requests. You could build the restlet endpoint upfront for each tenant like: https://ACCID.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=customscript_aura_rs&deploy=customdeploy_aura_rs To be on the safe side you can fetch the data center url for each client using GET on https://rest.netsuite.com/rest/datacenterurls?account=ACCID (no auth needed)
1