To access a single API, you can use cURL. For more information, see
. Since SSL
certificates on D9800 units are self-signed, you can use "-k DEFAULT" options to bypass the security checks
of the cURL command.
Example 1:
curl -k -i -H "X-SESSION-ID: $token" "https://192.168.0.1/ws/v2/test/show/id-eeprom"
Example 2:
curl -k "https://192.168.0.1/ws/v2/test/show/id-eeprom&session=$token"
The DEFAULT
–
k cipher option might not be available in older versions of the cURL command. An
updated version of the tool is required to enable this option. Follow your operating systems instructions
to update your cURL. For example, on CEL/Fedora, issue the following command as a root user and then
restart:
yum update curl
Note
The
–
H "X-SESSION-ID: $token"
(or
session=$token
) part of the cURL syntax is required for each command
in order to propagate the HTTP session_id. The
$token
represents a Linux (or Cygwin if that is the Host
environment) environment variable that is based on the value of the XML <SESSION></SESSION> item
from the successful Login response.
For an example of the login command, and setting the $token environment variable, see
and Logout), on page 2
.
Access Level (Login and Logout)
When you successfully log in to a session, an access level is assigned. Access levels are confirmed on a per
API basis, and depending on the access level, the behavior of the API may change.
1
No Access - No session available.
2
Guest - Guest session is active.
3
User - User session is active.
4
Admin - Admin session is active.
The following is an example of the Login command.
Input:
curl -k https://192.168.0.1/ws/v1/table?t=return -X POST -d
"<HDR><LOGIN><UID>admin</UID><USERPASS>localadmin</USERPASS></LOGIN></HDR>" -H "Content-Type:
text/xml; charset=UTF-8"
Expected output:
?xml version="1.0" encoding="ISO-8859-1"?>
<HDR><TABLE><ITEM><ID>STATUS</ID><VALUE>Please wait while the default page loads up
....</VALUE></ITEM><LOGIN_INFO><USER_NAME>admin</USER_NAME><USER_ROLE>ADMIN</USER_ROLE><SESSION_ID>TokenValue</SESSION_ID></LOGIN_INFO></TABLE></HDR>
Where Session
TokenValue
should be used in each subsequent Web Server API commands.
In each of the commands described in this document, the
–
H "X-SESSION-ID: $token"
(or appended
"session=$token"
) portion of the curl request syntax passes the value of
$token
environment variable.
Cisco D9800 Network Transport Receiver Version 2.75 RESTful Web Services API Reference Guide
2
Web Services API
Access Level (Login and Logout)