cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
865
Views
0
Helpful
1
Replies

NSO REST API using PUT to upload JSON configuration files

tcragg1
Cisco Employee
Cisco Employee

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?

 

 

1 Reply 1

Jan Lindblad
Cisco Employee
Cisco Employee

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.