07-03-2020 08:54 AM
I've been trying to use the yang-patch method with JSON data to write changes to device configurations in NSO, but have been having trouble making it work. Below is the JSON data I am trying to send to /restconf/data to configure an IOS device:
{ "ietf-yang-patch:yang-patch": { "patch-id": "test-patch", "edit": [ { "edit-id": "test1", "operation": "merge", "target": "/tailf-ncs:devices/device=hs4-inf-p-rr01/config/tailf-ned-cisco-ios:interface/GigabitEthernet0%2F0%2F5.51", "value": { "tailf-ned-cisco-ios:GigabitEthernet": [ { "name": "0/0/5.51", "description": "Test", } ] } } ] } }
This just returns a malformed-message error. When I attempt the same thing using XML with the following data, it works correctly:
<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch"> <patch-id>test-patch</patch-id> <edit> <edit-id>test1</edit-id> <operation>merge</operation> <target>/tailf-ncs:devices/device=hs4-inf-p-rr01/config/tailf-ned-cisco-ios:interface/GigabitEthernet=0%2F0%2F5.51</target> <value> <GigabitEthernet xmlns="urn:ios" xmlns:ios="urn:ios" xmlns:ncs="http://tail-f.com/ns/ncs"> <name>0/0/5.51</name> <description>Test</description> </GigabitEthernet> </value> </edit> </yang-patch>
Can anyone advise what I am doing wrong with the JSON?