<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HTTPError: 405 Client Error: Method Not Allowed when pushing yang data in Tools</title>
    <link>https://community.cisco.com/t5/tools/httperror-405-client-error-method-not-allowed-when-pushing-yang/m-p/3903329#M2116</link>
    <description>&lt;P&gt;This is known YDK &lt;A href="https://github.com/CiscoDevNet/ydk-gen/issues/917" target="_self"&gt;issue&lt;/A&gt;. Unfortunately the IOS XE does not allow to have non-secure Restconf connection and YDK does not support secure HTTP connection. We will fix that issue as resources permit.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Aug 2019 19:20:17 GMT</pubDate>
    <dc:creator>ygorelik</dc:creator>
    <dc:date>2019-08-05T19:20:17Z</dc:date>
    <item>
      <title>HTTPError: 405 Client Error: Method Not Allowed when pushing yang data</title>
      <link>https://community.cisco.com/t5/tools/httperror-405-client-error-method-not-allowed-when-pushing-yang/m-p/3902942#M2115</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm trying to push some data using nornir framework, however when I receive error 404: method not allowed Error.&lt;/P&gt;&lt;P&gt;I'm using IOS-XE version 16.9.3&amp;nbsp; with csr1000v as my&amp;nbsp; test environment.&lt;/P&gt;&lt;P&gt;Python version: 3.7.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There many policy-map configured on the device and what I'm trying to achieve is to change only a single policy-map config without changing other policy-maps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;He're is my code and It's respective host.yaml and groups.yaml file&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/python3

import requests
from nornir import InitNornir
from nornir.plugins.tasks.apis import http_method
from nornir.plugins.functions.text import print_result

def manage_devices(task, policy, headers):
    BaseURL = f'https://{task.host.hostname}:{task.host.port}/restconf/'
    task.run(
        task=http_method,
        name='Update policy-map and class-map config via HTTP PUT',
        method='put',
        url=BaseURL + policy,
        auth=('XXXX', 'ZZZZZ'),
        headers=headers,
        verify=False,
        json=task.host['body']['Cisco-IOS-XE-native:policy']['Cisco-IOS-XE-policy:policy-map'][0],
    )
def main():

    requests.packages.urllib3.disable_warnings()
    policy_header = 'data/Cisco-IOS-XE-native:native/Cisco-IOS-XE-native:policy/Cisco-IOS-XE-policy:policy-map/'
    PutHeader = {
      'Content-Type': 'application/yang-data+json',
      'Accept': 'application/yang-data+json, application/yang-data.errors+json'
    }
    nornir = InitNornir()
    result = nornir.run(
        task=manage_devices,
        name='Configure devices via RESTCONF',
        policy=policy_header,
        headers=PutHeader,
    )
    print_result(result)

if __name__ == '__main__':
    main()&lt;/PRE&gt;&lt;P&gt;hosts file:&lt;/P&gt;&lt;PRE&gt;---
PE-R2:
  hostname: '172.17.105.6'
  port: '8802'
  groups:
    - 'csr1000v'
  data:
    body:             
      Cisco-IOS-XE-native:policy:
        Cisco-IOS-XE-policy:class-map:
        - name: CLASS_TEST
          prematch: match-all
          match:
            access-group:
              name:
              - ACL_COUNT_TEST
        Cisco-IOS-XE-policy:policy-map:
        - name: POLICY_TEST
          class:
          - name: CLASS_TEST  
... &lt;/PRE&gt;&lt;P&gt;groups file&lt;/P&gt;&lt;PRE&gt;---
csr1000v:
 username: 'XXXX'
 password: 'ZZZZ'
 platform: 'ios'
 &lt;/PRE&gt;&lt;P&gt;It seems I'm not able to figure out the correct format to push configs to router.&lt;/P&gt;&lt;P&gt;I'm getting this Error message when running script:&lt;/P&gt;&lt;P&gt;requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: &lt;A href="https://172.17.105.6:8802/restconf/data/Cisco-IOS-XE-native:native/Cisco-IOS-XE-native:policy/Cisco-IOS-XE-policy:policy-map/" target="_blank" rel="noopener"&gt;https://172.17.105.6:8802/restconf/data/Cisco-IOS-XE-native:native/Cisco-IOS-XE-native:policy/Cisco-IOS-XE-policy:policy-map/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 09:16:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/httperror-405-client-error-method-not-allowed-when-pushing-yang/m-p/3902942#M2115</guid>
      <dc:creator>behnamyazdani</dc:creator>
      <dc:date>2019-08-05T09:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: HTTPError: 405 Client Error: Method Not Allowed when pushing yang data</title>
      <link>https://community.cisco.com/t5/tools/httperror-405-client-error-method-not-allowed-when-pushing-yang/m-p/3903329#M2116</link>
      <description>&lt;P&gt;This is known YDK &lt;A href="https://github.com/CiscoDevNet/ydk-gen/issues/917" target="_self"&gt;issue&lt;/A&gt;. Unfortunately the IOS XE does not allow to have non-secure Restconf connection and YDK does not support secure HTTP connection. We will fix that issue as resources permit.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 19:20:17 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/httperror-405-client-error-method-not-allowed-when-pushing-yang/m-p/3903329#M2116</guid>
      <dc:creator>ygorelik</dc:creator>
      <dc:date>2019-08-05T19:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: HTTPError: 405 Client Error: Method Not Allowed when pushing yang data</title>
      <link>https://community.cisco.com/t5/tools/httperror-405-client-error-method-not-allowed-when-pushing-yang/m-p/3903688#M2117</link>
      <description>&lt;P&gt;I'm not sure how is it related to that issue but the point is if I send without specifying nested keys like following snippet, configuration are pushed to router successfully:&lt;/P&gt;&lt;PRE&gt;json=task.host['body']&lt;/PRE&gt;&lt;P&gt;But when I try to push an specific part of the data, I receive '405 Client Error: Method Not Allowed for URL:'&lt;/P&gt;&lt;PRE&gt;json=task.host['body']['Cisco-IOS-XE-native:policy']['Cisco-IOS-XE-policy:policy-map'][0],&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2019 10:59:30 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/httperror-405-client-error-method-not-allowed-when-pushing-yang/m-p/3903688#M2117</guid>
      <dc:creator>behnamyazdani</dc:creator>
      <dc:date>2019-08-06T10:59:30Z</dc:date>
    </item>
  </channel>
</rss>

