diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
commit | 7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch) | |
tree | efb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/community/zabbix/plugins/httpapi | |
parent | Releasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff) | |
download | ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip |
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/zabbix/plugins/httpapi')
-rw-r--r-- | ansible_collections/community/zabbix/plugins/httpapi/zabbix.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py b/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py index 3db65532c..56ba0356d 100644 --- a/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py +++ b/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py @@ -165,12 +165,16 @@ class HttpApi(HttpApiBase): try: json_data = json.loads(value) if value else {} - if "result" in json_data: - json_data = json_data["result"] # JSONDecodeError only available on Python 3.5+ except ValueError: raise ConnectionError("Invalid JSON response: %s" % value) + if "error" in json_data: + raise ConnectionError("REST API returned %s when sending %s" % (json_data["error"], data)) + + if "result" in json_data: + json_data = json_data["result"] + try: # Some methods return bool not a dict in "result" iter(json_data) @@ -178,9 +182,6 @@ class HttpApi(HttpApiBase): # Do not try to find "error" if it is not a dict return response.getcode(), json_data - if "error" in json_data: - raise ConnectionError("REST API returned %s when sending %s" % (json_data["error"], data)) - return response.getcode(), json_data except AnsibleConnectionFailure as e: self.connection.queue_message("vvv", "AnsibleConnectionFailure: %s" % e) |