Skip to content

Commit 2b47ed2

Browse files
committed
Fix update_application method
Returning 400 Bad Request errors. Request body should be JSON encoded instead of application/x-www-form-urlencoded.
1 parent e847d20 commit 2b47ed2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

nexmo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def put(self, host, request_uri, params):
235235

236236
params = dict(params, api_key=self.api_key, api_secret=self.api_secret)
237237

238-
return self.parse(host, requests.put(uri, data=params, headers=self.headers))
238+
return self.parse(host, requests.put(uri, json=params, headers=self.headers))
239239

240240
def delete(self, host, request_uri):
241241
uri = 'https://' + host + request_uri

test_nexmo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ def test_update_application(self):
463463

464464
self.assertIsInstance(self.client.update_application('xx-xx-xx-xx', params), dict)
465465
self.assertEqual(request_user_agent(), self.user_agent)
466-
self.assertIn('answer_url=https%3A%2F%2Fexample.com%2Fncco', request_body())
466+
self.assertEqual(request_content_type(), 'application/json')
467+
self.assertIn(b'"answer_url": "https://example.com/ncco"', request_body())
467468

468469
@responses.activate
469470
def test_delete_application(self):

0 commit comments

Comments
 (0)