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>
Merge pull request #2 from benagricola/master

Handle errors from put requests correctly