Skip to content

Commit

Permalink
[FIX] Send data via JSON in call
Browse files Browse the repository at this point in the history
  • Loading branch information
lasley committed Dec 27, 2016
1 parent d3498cf commit 8b94611
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions red_october/red_october.py
Expand Up @@ -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
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion red_october/tests/test_red_october.py
Expand Up @@ -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,
)

Expand Down

0 comments on commit 8b94611

Please sign in to comment.