Fix HTTP 405 response

This was not a JSON response.
Convert all HTTP errors to JSON