RE: How to access the parameters in a restlet call?

Previously while using client script I used to call a restlet using https.get(option) function. I attach the parameters need in the URL and access those parameters in restlet through context

I am trying to call a restlet from a User Event Script using https.requestrestlet(options) function. but I am unable to access the parameter values. any information is highly appreciated.

thank you

Lionheart Rookie Asked on May 19, 2021 in SuiteScript.
Add Comment
1 Answers

//Restlet

define([‘N/record’, ‘N/error’],
   function(record, error) {

        function _get(context) {
              return JSON.stringify(record.load({
              type: context.recordtype,
              id: context.id
        }));

        }

        return {
              get: _get
        };
});


//Call Restlet
var
restHeader = { headerType: 'test'  };
var urlPara = { recordtype: 'salesorder', id: '259753' }
var restResp = https.requestRestlet({ body: 'Test Restlet body', deploymentId: 'deploy1', headers: restHeader, method: 'GET', scriptId: 101, urlparams: urlPara });
Rookie Answered on May 20, 2021.

Thank you for your response. I have tried the below code:

// Restlet call:


var urlPara = {woId:'11456146'};

var restHeader = { headerType: 'test' };

var setValues = https.requestRestlet({

body: 'Test Restlet body',

deploymentId: 'customdeploy1',

headers: restHeader,

method: 'GET',

scriptId: 475,

urlparams: urlPara

});

log.debug({title:'data',details:setValues.body})

and the Restlet code:


/**

*@NApiVersion 2.x

*@NScriptType restlet

*/

define([],

function(){

function quoteGet(context){

log.debug({title:'restletbody',details:context.woId})

return JSON.stringify(context)

}

return {

get: quoteGet

}

}

)

but I didn’t get the parameters the restlet call has returned blank as in the below picture.

RE: How to access the parameters in a restlet call?

on May 24, 2021.

Please try “setValues.getBody()” instead of “setValues.body”.

on May 26, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.