added JSON response for REST API errors - rjrjr