Outbound REST with error handling
Use a REST Message record for the endpoint and auth; keep secrets out of scripts.
try {
var rm = new sn_ws.RESTMessageV2('x_rsa_vendor_api', 'get_ticket');
rm.setStringParameterNoEscape('id', current.getValue('correlation_id'));
rm.setHttpTimeout(30000);
var res = rm.execute();
var status = res.getStatusCode();
if (res.haveError() || status >= 400) {
gs.error('Vendor API ' + status + ': ' + res.getErrorMessage());
} else {
var body = JSON.parse(res.getBody());
// map body -> fields
}
} catch (e) {
gs.error('Vendor API call failed: ' + e.message);
}