2106 - Added error handling for invalid json responses

- This change also works to fix bad 3xx redirects as noted in #2106.