04-18-2021 05:56 PM
Hello,
I am trying to construct the curl call to push a device config onto an existing device on NSO.
Similar to this: https://community.cisco.com/t5/nso-developer-hub-discussions/rest-api-for-config-push-onto-nso-device/m-p/3604043#M2330 but this discussion did not include the actual curl path to execute the call.
I have tried:
curl -H "Content-Type:applicaiton/vnd.yang.data+xml" -X PUT -d @sample.xml http:localhost:8080/api/running/devices/device/device-name -u user:password
Response:
<errors xmlns="http://tail-f.com/ns/tailf-rest-error">
<error>
<error-tag>malformed-message</error-tag>
<error-urlpath>/api/running/devices/device/device-name</error-urlpath>
<error-message>unknown element: devices in /ncs:devices/ncs:devices</error-message>
</error>
</errors>
04-19-2021 06:40 AM - edited 04-19-2021 06:40 AM
In recent versions, the pre-standard REST API has been deprecated in favor of the standard RESTCONF.
Your call would now look like:
curl --location -u user:password --request GET 'http://127.0.0.1:8080/restconf/data/tailf-ncs:devices/device=ce1' \ --header 'Accept: application/yang-data+json'
04-19-2021 08:56 AM
Hello,
I did some digging and found out restconf should be the new way to do the call. This call seems to retrieves the config, but I was wondering if there is a way to push the config to a device?
04-19-2021 09:10 AM
05-24-2021 09:25 AM - edited 05-24-2021 09:27 AM
https://gitlab.com/nso-developer/rest-api-explorer builds curl commands automatically by a few GUI clicks.
05-26-2021 05:29 AM
I also suggest that you should use the standardized RESTCONF protocol.
I note however that there might be a mismatch in the path?
The request
curl -H "Content-Type:applicaiton/vnd.yang.data+xml" -X PUT -d @sample.xml http:localhost:8080/api/running/devices/device/device-name -u user:password
In the response error it says
<error-urlpath>/api/running/devices/device/device-name</error-urlpath>
<error-message>unknown element: devices in /ncs:devices/ncs:devices</error-message>
Is there a spurios "s" in the payload's device element perhaps?
Perhaps it says
<devices>
<devices>
<name>device-name</name>
Note the *two* devices elements, the latter should be <device> only.
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