Added some basic error handling to deal with potentially bad JSON responses from the server

We have had problems when the server does not provide a proper implementation for application/json content types in REST requests. While the server implementation is ultimately at fault, this causes the entire node.js application to crash.

The error handling will prevent this from happening.