From 8b946118164dc608e8ca698118c05a305dd72dd8 Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Sat, 24 Dec 2016 15:53:44 -0800 Subject: [PATCH] [FIX] Send data via JSON in `call` --- red_october/red_october.py | 17 +++++++++-------- red_october/tests/test_red_october.py | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/red_october/red_october.py b/red_october/red_october.py index c4bdc34..d9bf081 100644 --- a/red_october/red_october.py +++ b/red_october/red_october.py @@ -337,9 +337,9 @@ def call(self, endpoint, method='POST', params=None, data=None): Args: endpoint (str): RedOctober endpoint to call (e.g. ``newcert``). method (str): HTTP method to utilize for the Request. - params: (dict|bytes) Data to be sent in the query string + params: (dict or bytes) Data to be sent in the query string for the Request. - data: (dict|bytes|file) Data to send in the body of the + data: (dict or bytes or file) Data to send in the body of the Request. Raises: RedOctoberRemoteException: In the event of a ``False`` in the @@ -350,16 +350,17 @@ def call(self, endpoint, method='POST', params=None, data=None): success. """ endpoint = '%s/%s' % (self.uri_base, endpoint) - if data: - data.update({ - 'Name': self.name, - 'Password': self.password, - }) + if data is None: + data = {} + data.update({ + 'Name': self.name, + 'Password': self.password, + }) response = requests.request( method=method, url=endpoint, params=params, - data=data, + json=data, verify=self.verify, ) response = response.json() diff --git a/red_october/tests/test_red_october.py b/red_october/tests/test_red_october.py index 685cfaf..5f83453 100644 --- a/red_october/tests/test_red_october.py +++ b/red_october/tests/test_red_october.py @@ -196,7 +196,7 @@ def test_call_request(self, requests): method='method', url='https://test:1/endpoint', params='params', - data=data, + json=data, verify=True, )