Edit config through REST API

‎12-31-201901:15 PM

Is it possible to edit the config of a junos device using the REST API? I see that it has both GET and POST capabilities, but I can't find any information online about how to edit a device's config. I've gotten it to work for reading data from the device, but I would like to update the config this way as well.

Re: Edit config through REST API

‎01-01-202007:28 AM

Great, thank you! That's exactly what I was looking for.

One more thing though, is there a JSON counterpart to the <lock-configuration>, <load-configuration>, and <commit> elements? I'm storing my variables in YAML, so it would be great to be able to just feed the variable dict to to_json in ansible but I'm not sure what to do about those elements.

Re: Edit config through REST API

‎01-02-202006:20 AM

Alright, so according to the whitepaper PDF "JSON Support for Junos OS", the data control parameters will still be in XML, so things like commit, load-configuration, etc will still be held within XML tags. In theory you can supply the configuration in JSON within the <configuration-json> XML tags, but this appears to only be supported on some devices. The device I'm working on does not support this, so I'm left generating XML from the YAML variables, which isn't ideal but gets the job done.