diff --git a/changelogs/fragments/58015-yang-types.yaml b/changelogs/fragments/58015-yang-types.yaml new file mode 100644 index 00000000000..2c53dce32e8 --- /dev/null +++ b/changelogs/fragments/58015-yang-types.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Fix media type of RESTCONF requests. diff --git a/lib/ansible/module_utils/network/restconf/restconf.py b/lib/ansible/module_utils/network/restconf/restconf.py index 375cd0a95be..81a26bff44d 100644 --- a/lib/ansible/module_utils/network/restconf/restconf.py +++ b/lib/ansible/module_utils/network/restconf/restconf.py @@ -39,7 +39,7 @@ def get(module, path=None, content=None, fields=None, output='json'): accept = None if output == 'xml': - accept = 'application/yang.data+xml' + accept = 'application/yang-data+xml' connection = Connection(module._socket_path) return connection.send_request(None, path=path, method='GET', accept=accept) @@ -51,7 +51,7 @@ def edit_config(module, path=None, content=None, method='GET', format='json'): content_type = None if format == 'xml': - content_type = 'application/yang.data+xml' + content_type = 'application/yang-data+xml' connection = Connection(module._socket_path) return connection.send_request(content, path=path, method=method, content_type=content_type) diff --git a/lib/ansible/plugins/httpapi/restconf.py b/lib/ansible/plugins/httpapi/restconf.py index b883ccaf4b2..ad5bd999188 100644 --- a/lib/ansible/plugins/httpapi/restconf.py +++ b/lib/ansible/plugins/httpapi/restconf.py @@ -48,7 +48,7 @@ from ansible.module_utils.six.moves.urllib.error import HTTPError from ansible.plugins.httpapi import HttpApiBase -CONTENT_TYPE = 'application/yang.data+json' +CONTENT_TYPE = 'application/yang-data+json' class HttpApi(HttpApiBase):