Discussões
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Please note that on Saturday, April 11, 2026, at 8:00 PM Pacific time, our Case Management System will undergo a scheduled maintenance for approximately 30 minutes. During this time, case creation via SuiteAnswers will be unavailable and inbound calls will be routed to Customer Service.
Enviar um POST request de um Suitelet a um Restlet
Aplica-se a
Produto: NetSuite 2020.2
Cenário
O usuário deseja criar um Suitelet que envie dados para um RESTlet que crie um registro de Cliente.
Solução
Crie 2 scripts. Um é um Suitelet que prepara os dados do cliente e chama o RESTlet. A outra é um RESTlet que cria o registro do Cliente com os dados fornecidos pelo Suitelet.
Suitelet:
SuiteScript 1.0
function requestFromForm(request, response) {
if (request.getMethod() == 'GET') {
//create a form where users could enter data
var form = nlapiCreateForm('Simple Form');
var companyname = form.addField('companyname', 'text', 'Company:');
form.addSubmitButton('Submit');
response.writePage(form);
} else {
//when form is submitted create and send the request to the Restlet
try {
//URL of Restlet
var url = "https://rest.netsuite.com/app/site/hosting/restlet.nl?script=108&deploy=1";
//Authorization header
var authorization = "NLAuth nlauth_account=TSTDRV12345,nlauth_email=email@netsuite.com, nlauth_signature=*******,nlauth_role=3";
//Create the request headers
var headers = new Array();
headers['Content-Type'] = 'application/json';
headers['Authorization'] = authorization;
headers['User-Agent-x'] = 'SuiteScript Call';
//obtain the values entered by the user
var companyname = request.getParameter('companyname');
var isperson = false;
//format the data to be submitted; for this instance I used JSON
var jsonString = "{\"companyname\":\"" + companyname + "\",\"isperson\":" + isperson + "}";
//send the request to
Rotulado:
0
Olá, bem-vind@!
Faça login
Para ver todos os detalhes, faça o login.
Cadastre-se
Não tem uma conta? Clique aqui para começar!