Move error handling code to post json parsing

Current error handling code attempts to reference a string a dict, all requests fail.