Handle errors from put requests correctly

Also json_encode put value when passed as a table

Signed-off-by: Ben Agricola <bagricola@squiz.co.uk>