Error when using Edge HttpClient while retrieving a value from JSON response

Not applicable
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 \""
    }
}
1 1 817
1 REPLY 1

looks like responseObj is null or undefined, try inspecting exchange.getResponse(), look for status code, raw content and make sure this is what you are expecting to see