Hi, I'm getting error while retrieving a value from a JSON response. Not sure why it is throwing error at responseObj.error. Please advise. Thanks!
Sample:
function () {
// .........................
var bodyObj = {};
var req = new Request(oauthURL, 'POST', headers, JSON.stringify(bodyObj));
var exchange = httpClient.send(req);
exchange.waitForComplete();
if (exchange.isSuccess()) {
var responseObj = exchange.getResponse().content.asJSON;
if (responseObj.error) {
throw new Error(resp.content);
}
}
else if (exchange.isError()) {
throw new Error(exchange.getError());
}
}
Error:
{
"fault": {
"detail": {
"errorcode": "steps.javascript.ScriptExecutionFailed"
},
"faultstring": "Execution of sendRTMMail failed with error: Javascript runtime error: \"TypeError: Cannot read property \"error\" from undefined (SendMail_js#35). at line 35 \""
}
}