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
//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 });
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.
Please try “setValues.getBody()” instead of “setValues.body”.
