cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1444
Views
5
Helpful
4
Replies

yang-patch with JSON data

tcragg1
Cisco Employee
Cisco Employee

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?

4 Replies 4

rogaglia
Cisco Employee
Cisco Employee

Could it be that:

"description": "Test",   <--- remove final comma

Unfortunately not, I still just get a malformed message error if I remove that comma and re-try.

perander
Cisco Employee
Cisco Employee
I could reproduce this with a toy example. It seems to be bug and I filed a ticket for it.

Was this ever fixed? Seeing the same problem on 5.3.2.4.