08-11-2020 08:51 AM
Hi, I have some server with a leaf-list in it.
I want to edit the elements in this leaf-list via RESTCONF.
If I do something like this:
curl -i -X PATCH http://X.X.X.X:YYY/restconf/data/services/myservice -H "Content-Type: application/yang-data+json" --data '{"myservice:serviceA": [ {"label": "new-label"}]}'
The leaf-list "label" adds the string "new-label". But sometime I want to replace the entire content of "label" with my new label, and not just add the new string to the list.
Is it possible to do this? What path or method do I need to pass?
Thanks
Solved! Go to Solution.
08-12-2020 06:30 AM - edited 08-12-2020 08:53 AM
I meat a PUT directly into the leaf-list and not on the service list above.
Your URL should look like:
http:/X.X.X.X:YYY/restconf/data/services/myservice=serviceA/label
And the encoding something like:
{"lable": [123, 0]}
08-11-2020 10:54 AM
08-11-2020 12:00 PM
If I use PUT, NSO try tu make a new instance of myservice and I get an error. Maybe the restconf path is wrong
My service:
list myservice{ key "code"; leaf code { type string; } ... leaf-list label { type string; } }
RESTCONF:
curl -i -X PUT http:/X.X.X.X:YYY/restconf/data/services/myservice -H "Content-Type: application/yang-data+json" --data '{"myservice:myservice": [ {"code": "serviceA", "label": "new-label"}]}'
Is any good way to know the correct url for restconf?. Maybe in cli with commit dry-run | display keypath or something like that.
08-12-2020 06:30 AM - edited 08-12-2020 08:53 AM
I meat a PUT directly into the leaf-list and not on the service list above.
Your URL should look like:
http:/X.X.X.X:YYY/restconf/data/services/myservice=serviceA/label
And the encoding something like:
{"lable": [123, 0]}
08-12-2020 08:42 AM
Thats works,
Thank you!
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