suport arbitrary json responses in rest request errors

This is supposed to fix issue #525