Encodes entire JSON string into request

Also fixes bug in error message