From f76bcb329f3a5c5fa99b0994f5fe7ff0b905744f Mon Sep 17 00:00:00 2001 From: Guillaume Badi Date: Mon, 20 Jun 2016 11:51:05 +0200 Subject: [PATCH] fix put json --- mailjet/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mailjet/client.py b/mailjet/client.py index 3067c48..cc9fee9 100644 --- a/mailjet/client.py +++ b/mailjet/client.py @@ -51,6 +51,8 @@ def create(self, data=None, filters=None, id=None, action_id=None, **kwargs): return api_call(self._auth, 'post', self._url, headers=self.headers, resource_id=id, data=data, action=self.action, action_id=action_id, filters=filters, **kwargs) def update(self, id, data, filters=None, action_id=None, **kwargs): + if self.headers['Content-type'] == 'application/json': + data = json.dumps(data) return api_call(self._auth, 'put', self._url, resource_id=id, headers=self.headers, data=data, action=self.action, action_id=action_id, filters=filters, **kwargs) def delete(self, id, **kwargs): @@ -84,8 +86,6 @@ def api_call(auth, method, url, headers, data=None, filters=None, resource_id=No try: response = req_method(url, data=data, params=filters, headers=headers, auth=auth, timeout=timeout, verify=False, stream=False) - - # return parse_response(response, debug=debug) return response except requests.exceptions.Timeout: