I'm trying to call a RESTlet from another script, ...
# suitescript
m
I'm trying to call a RESTlet from another script, in this case a Suitelet, and in the past I've done this using url.resolveScript. Here's the code I'm using:
Copy code
var suiteletURL = url.resolveScript({
            scriptId: 'customscript_rl_test',
            deploymentId: 'customdeploy_rl_test',
            returnExternalUrl: false
        });
   
        var response = https.get({url: suiteletURL});

        log.debug({title: "response", details: response});
But this is what I get:
Copy code
SSS_INVALID_URL
{
   type: "error.SuiteScriptError",
   name: "SSS_INVALID_URL",
   message: "The URL must be a fully qualified HTTPS URL.",
   id: null,
   stack: [
      "createError(N/error)",
      "execute(/SuiteScripts/CSG_SS_Test.js:16)",
      "createError(N/error)"
   ],
   cause: {
      name: "SSS_INVALID_URL",
      message: "The URL must be a fully qualified HTTPS URL."
   },
   notifyOff: false,
   userFacing: true
}
Obviously I can return a FQDN from getURL, but then I'd need to pass authentication info, which is what I'm trying to avoid here. Am I doing something obvious wrong? This looks identical to how I've done it in the past.
m
Not sure why it would have stopped working, but as of 2020.2, you can call
https.requestRestlet()
rather than
url.resolveScript
followed by
https.get
. Authorization headers are automatically added to your request so you don't have to build them.
this 1
e
m
Ahh awesome. I'll try that now. Thanks, guys!
e
Be aware it's only available server-side
m
Yep. That's what I want. Thank you!
Works. Awesome. Just in case anyone else searches for this:
Copy code
var response = https.requestRestlet({
            //body: "", Optional, put body here for NON-GET methods
            deploymentId: 'customdeploy_rl_test',
            method: 'GET',
            scriptId: 'customscript_rl_test',
            //urlParams: {} Optional, put parameters here
        });
💯 1