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?
07-08-2020 12:32 PM
Could it be that:
"description": "Test", <--- remove final comma
07-09-2020 06:01 AM
Unfortunately not, I still just get a malformed message error if I remove that comma and re-try.
07-09-2020 05:23 PM
10-16-2020 07:12 AM
Was this ever fixed? Seeing the same problem on 5.3.2.4.
09-11-2025 09:24 AM
I realize this is 5 years later so probably not helpful, but I landed here searching for help with something else and noticed what might have been your problem.. In your JSON example, your target value is missing an `=` between the interface node name "GigabiteEthernet" and the key "0/0/5.51". In your XML example (which you said works) you did include the `=` sign.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide