08-24-2021 02:25 AM
Hi, Team
Trying to create NSO new device via restconf query, but recieve error.
[admin@servername ~]$ curl -u admin -X POST -H "Accept: application/yang-data+xml" -H "Content-type: application/yang-data+xml" http://192.168.0.100:8080/restconf/data/tailf-ncs:devices \
> -d '{
> <devices xmlns="http://tail-f.com/ns/ncs">
> <device>
> <name>LAB-vXR-2</name>
> <address>10.21.90.69</address>
> <port>22</port>
> <description>Cisco__ASR</description>
> <authgroup>authgroup1</authgroup>
> <device-type>
> <cli>
> <ned-id xmlns:cisco-iosxr-cli-7.33="http://tail-f.com/ns/ned-id/cisco-iosxr-cli-7.33">cisco-iosxr-cli-7.33:cisco-iosxr-cli-7.33</ned-id>
> <protocol>ssh</protocol>
> </cli>
> </device-type>
> <state>
> <admin-state>unlocked</admin-state>
> </state>
> </device>
> </devices>
> }'
Enter host password for user 'admin ':
Error:
<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<error>
<error-type>application</error-type>
<error-tag>malformed-message</error-tag>
<error-path xmlns:ncs="http://tail-f.com/ns/ncs">/ncs:devices</error-path>
</error>
</errors>
May anyone show what am i doing wrong ??
Solved! Go to Solution.
08-27-2021 02:46 AM
There are a few options. You can add the "-v" or "--verbose" flag to the curl command to show the response header you received.
If all you are interested in is the status code, you can try adding the following flags to the curl command, which print the status code value received from the NSO server:
-s -o /dev/null -w "\n%{http_code}\n"
Alternatively, you could do a RESTCONF GET request for the object you just created and verify that it is present and correctly configured.
08-24-2021 06:55 AM
I think the opening and closing {} characters are causing it to be rejected as malformed XML. Try removing them and re-sending.
08-26-2021 05:14 AM
Thanks, it works now, device is crated correctly! But i don`t recive any message from curl about success, how may i fix it?
[admin@servername ~]$ curl -u admin -X POST -H "Accept: application/yang-data+xml" -H "Content-type: application/yang-data+xml" http://192.168.0.100:8080/restconf/data/tailf-ncs:devices \
> -d '<device>
> <name>LAB-vXR-2</name>
> <address>10.21.90.69</address>
> <port>22</port>
> <description>Cisco__ASR</description>
> <authgroup>authgroup1</authgroup>
> <device-type>
> <cli>
> <ned-id xmlns:cisco-iosxr-cli-7.33="http://tail-f.com/ns/ned-id/cisco-iosxr-cli-7.33">cisco-iosxr-cli-7.33:cisco-iosxr-cli-7.33</ned-id>
> <protocol>ssh</protocol>
> </cli>
> </device-type>
> <state>
> <admin-state>unlocked</admin-state>
> </state>
> </device>'
Enter host password for user 'admin ':
[admin@servername ~]$
08-27-2021 02:46 AM
There are a few options. You can add the "-v" or "--verbose" flag to the curl command to show the response header you received.
If all you are interested in is the status code, you can try adding the following flags to the curl command, which print the status code value received from the NSO server:
-s -o /dev/null -w "\n%{http_code}\n"
Alternatively, you could do a RESTCONF GET request for the object you just created and verify that it is present and correctly configured.
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