diff --git a/changelogs/fragments/3867-jira-fix-body.yaml b/changelogs/fragments/3867-jira-fix-body.yaml new file mode 100644 index 0000000000..0edb395e70 --- /dev/null +++ b/changelogs/fragments/3867-jira-fix-body.yaml @@ -0,0 +1,2 @@ +bugfixes: + - jira - fixed bug where module returns error related to dictionary key ``body`` (https://github.com/ansible-collections/community.general/issues/3419). diff --git a/plugins/modules/web_infrastructure/jira.py b/plugins/modules/web_infrastructure/jira.py index 942a804556..676b4620d2 100644 --- a/plugins/modules/web_infrastructure/jira.py +++ b/plugins/modules/web_infrastructure/jira.py @@ -694,7 +694,14 @@ class JIRA(StateModuleHelper): try: error = json.loads(info['body']) except Exception: - self.module.fail_json(msg=to_native(info['body']), exception=traceback.format_exc()) + msg = 'The request "{method} {url}" returned the unexpected status code {status} {msg}\n{body}'.format( + status=info['status'], + msg=info['msg'], + body=info.get('body'), + url=url, + method=method, + ) + self.module.fail_json(msg=to_native(msg), exception=traceback.format_exc()) if error: msg = [] for key in ('errorMessages', 'errors'):