From 9d0b8c854528d7f23707c73b8f65f6a9de60cbf6 Mon Sep 17 00:00:00 2001 From: Eric Chou Date: Wed, 23 Nov 2016 08:10:58 -0800 Subject: [PATCH] modified POST body in axapi_authenticate_v3() and axapi_call_v3() (#18104) --- lib/ansible/module_utils/a10.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/a10.py b/lib/ansible/module_utils/a10.py index 82492a8595..389ef4aba5 100644 --- a/lib/ansible/module_utils/a10.py +++ b/lib/ansible/module_utils/a10.py @@ -30,6 +30,7 @@ import json from ansible.module_utils.urls import fetch_url + AXAPI_PORT_PROTOCOLS = { 'tcp': 2, 'udp': 3, @@ -91,7 +92,7 @@ def axapi_authenticate(module, base_url, username, password): def axapi_authenticate_v3(module, base_url, username, password): url = base_url auth_payload = {"credentials": {"username": username, "password": password}} - result = axapi_call_v3(module, url, method='POST', body=auth_payload) + result = axapi_call_v3(module, url, method='POST', body=json.dumps(auth_payload)) if axapi_failure(result): return module.fail_json(msg=result['response']['err']['msg']) signature = result['authresponse']['signature'] @@ -105,7 +106,7 @@ def axapi_call_v3(module, url, method=None, body=None, signature=None): headers = {'content-type': 'application/json', 'Authorization': 'A10 %s' % signature} else: headers = {'content-type': 'application/json'} - rsp, info = fetch_url(module, url, method=method, data=json.dumps(body), headers=headers) + rsp, info = fetch_url(module, url, method=method, data=body, headers=headers) if not rsp or info['status'] >= 400: module.fail_json(msg="failed to connect (status code %s), error was %s" % (info['status'], info.get('msg', 'no error given'))) try: