11-09-2018 06:23 AM
I am trying to use the NSO REST API to push full device configurations via NSO (the idea is that devices will have a source controlled configuration file, and the full updated configuration file for a device will be pushed into NSO whenever there is an approved change). When I use XML for the configuration files, it appears to work correctly. However, when I use JSON, I get a 400 Bad Request error with a message similar to the following on a dry-run:
{"errors": {"error": [{"error-message": "unknown element: number-standard in /ncs:devices/ncs:device[ncs:name='c0']/ncs:config/ios:ip/ios:community-list/ncs:number-standard", "error-urlpath": "/api/running/devices/device/c0/config", "error-tag": "malformed-message"}]}}
The JSON file I am using is just one I downloaded with a GET to /api/running/devices/device/c0/config?deep, so the dry-run should just return no differences (and the equivalent XML file does return no differences on a dry-run).
Is it supported to use a JSON file with a PUT command to /api/running/devices/device/{device_name}/config to update the configuration on a device, or do I need to use XML?
11-12-2018 06:28 AM
I'm not sure if you're using the legacy REST or the more modern RESTCONF interface; I would recommend the latter.
When it comes to your problem, the error message refers to ncs:number-standard as missing. This makes good sense, since I'm pretty sure there's no number-standard in the ncs: namespace. You need to qualify number-standard with the correct namespace.
While there are a number of NETCONF operations using XML that are unavailable in RESTCONF, there is no functional difference between the XML and JSON representations.
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