cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1073
Views
0
Helpful
4
Replies

execute show command via REST API error

syuefeng
Cisco Employee
Cisco Employee

Hi team,

 

I am trying to get the output of "show running" command using live-stats via the REST API,  i follow somebody's guide,

 

url as below:

 

curl -v -X POST -T show_running.xml -u admin:admin localhost:8080/api/operational/devices/device/SR-CISCO9K/live-status/cisco-ios-xr-stats:exec/_operations/show

 

payload as below

<show>
  <args>running</args>
</show>

 

but i get some error message, any ideas on how to build the correct url to query this?

 

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">
<error>
<error-tag>malformed-message</error-tag>
<error-urlpath>/api/operational/devices/device/SR-CISCO9K/live-status/cisco-ios-xr-stats:exec/show</error-urlpath>
<error-message>Unexpected content: '
  '</error-message>
</error>
</errors>

1 Accepted Solution

Accepted Solutions

Jan, really thank you for your message , it's very important for me, thanks.

View solution in original post

4 Replies 4

Jan Lindblad
Cisco Employee
Cisco Employee

I'm not entirely sure where you are headed with this, but if you really want to ask the device to show running config and get a string back for you to parse on your own, you should probably use the resource

 

localhost:8080/api/operational/devices/device/SR-CISCO9K/live-status/cisco-ios-xr-stats:exec/_operations/any

with payload

<any>
<args>show</args>
<args>running</args>
</any>

 

Also, you are using the old REST API. I would recommend that you to switch to standard RESTCONF instead.

Hi Jan ,thank you for your quickly answer, i got this info from below link

https://community.cisco.com/t5/jive-developer-archive/accessing-device-live-status-over-api/td-p/3552950

 

My customer have some app in development, Our arch team suggest customer to use REST API,  Are you sure we will use RESTCONF to replace the REST api?  , if so, I need give some message to customer.

 

also, i have got the config using your way ,it's correct, but i found &#13  at the tail of every line, can i eliminate them?

logging events level informational&#13;
logging monitor informational&#13;

As far as I am aware, the REST interface is not going away soon, but the development of it has stopped. Why use a proprietary, old and not developing interface when there is a newer, standard and living interface also based on REST, i.e. RESTCONF?

 

The string you get back from this action is the raw response from the device. It contains those line breaks, which you are of course free to remove. This whole approach, to use NSO to access the raw text output of the device that you have to massage and parse yourself, might seem a little odd and brittle.

Jan, really thank you for your message , it's very important for me, thanks.