Rectify sanity checks

* By default, the API returns a JSON encoded string. Use a try/catch
block to trap any exceptions that are thrown when the decode
fails or detects invalid parameters