Add header to Restlet response

I develop mobile application, but developing and debugging cloud environment need to add one header for rest response header.

so, I tried writing below at first,

function _get(context) {

context.response.addHeader('header-name', 'header-value');

but Netsuite returns

org.mozilla.javascript.EcmaError: TypeError: Cannot call method "addHeader" of undefined (/SuiteScripts/file-name.js#lineXX)

Netsuite Support teams  said,

Restlet cannot user Addheader, suitlet only .


Can any one please suggest below 2 questions,

at first , Is Netsuite team Ture?

second, If it is true, Is below my idea  feasible? or  Is there anyone who has already try it?


my idea :

when Real machine debugging, direct call restlet,

bud when debugging as below

entry suitelet ()
→ call restlet()
←  return json object
response.headers = request.headers
response.headers.add('header-name', 'header-value');
return response
Rookie Asked on August 5, 2021 in SuiteScript.
Add Comment
1 Answer(s)

This Problem has  already been resolved.

I created wrapper function for the restlet and  the details are omitted


 function wrapperRestlet(param) {
            var _url = param.url;
            var _script = param.script;
            var _deploy = param.deploy;
            var _contexttype = param.contexttype;
            var _authorization = param.auth;
            _url = _url + "?script=" + _script + "&deploy=" + _deploy;
            var _headers= {
                'Content-Type' : _contexttype,
                'Authorization' : _authorization,
            var clientResponse = https.get({
                    url: _url,
                    headers: _headers,
            return   clientResponse.body;

and ,  wrapper function calling is…

function onRequest(context) {
            var output: wrapperRestlet(JSON.parse(context.request.body););


POST (Suitelet ‘s args)  ‘sample is below

url = baseUrl,                                               //

script = SCRIPT_ID,

deploy = DEPLOY_ID,

contexttype = "application/json"

auth = _auth,                                                //  OAUTH outh_xxxxxxxxxxxx


Rookie Answered on August 10, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor