Showing results for 
Search instead for 
Did you mean: 



Is there a way to load a device directly into NSO via REST API?

For example, a device can be loaded via configuration CLI, such as following example, however is there a way to do so via REST API?

devices {

    device TEXAS {


        port      22;

        authgroup NSOAUTH;

        device-type {



        state {

            admin-state unlocked;



Cisco Employee

Yes, please see Create a device using REST.

I used CURL as follows:

curl -H "Content-Type:application/" -X PUT -u admin:admin -d testxr.xml http://x.x.x.x:8080/api/running/devices/device/testxr


<devices xmlns="">










        <ned-id xmlns:ned="">ned:netconf</ned-id>





When I run that CURL script, I get the following error:

<errors xmlns="">




    <error-message>End-of-file reached in XML stream</error-message>



Can you identify anything that I am doing wrong based upon this output?  Also note that I am running NSO version 4.4

Can you try adding @ before the filename for -d option?

-d @testxr.xml

Without @, you are sending the string "testxr.xml"

I tried it with the @ sign, however the error remains the same.

I note that in your example, the xml file has the "device" hierarchical html tag followed by the "name" hierarchical html tag as listed here:

<device xmlns="">


Conversely, when I display XML under the device configuration hierarchy for NSO4.4, the structure is different in that the namespace begins with "devices" hierarchical html tag, followed by "device" and then "name" as shown below:

<devices xmlns="">



I'm wondering if the XML format that I'm using is incorrect.  Do note that I have alternatively started my XML format at the <device> hierarchy, attempting to mirror your format, however it didn't work.


Yes, I believe you'll need to remove the <devices> tag. The payload shouldn't include the entire "path" to the config, e.g. in your case you shouldn't include "/devices/device/" only "device", if that makes sense.

I'd suggest you download the example for "ios3" and modify that to your needs.

I just pulled it down verbatim and loaded it, however I get the same error.

I assume that this is a cut-n-paste from a known working API from your system.

Are you using NSO version 4.4?

Yes, 4.4 and I cannot reproduce this, I pasted in the xml from the other post (I've attached it here) and ran:

➜  tmp curl -H "Content-Type:application/" -X PUT -u admin:admin -d @ios3.xml http://localhost:8080/api/running/devices/device/ios3

➜  tmp

And it works.

Please download the attached xml and see it makes a difference.


  It worked like a charm!  Thank you very much!

  I was already able to push both device and service templates via the API, however I wasn't able to actually discover the devices via the API.  Now that you've helped me out, I can discover the devices, sync configs, etc.  This will allow me to build a good, robust web-portal for my customer with NSO as the underpinning muscle!

Thank you VERY much!!

Glad to help!

This does not work anymore

Use this instead:


Then NED ID syntax in the XML file changes see the post linked above

The closing tag for <device> is missing the slash, </device>.

Given that to fully add the device to NSO, the ssh key of the device needs to be fetched too, has anyone figured out how to handle that part as well via REST API? 


admin@ncs> request devices device R02 ssh fetch-host-keys 


the key fetched from above command should fit in XYZ below.