Connectivity Guide

RESTCONF API tasks
Using the RESTCONF API, you can provision OS10 switches using HTTPS requests. The examples in this section show how to access the
OS10 RESTCONF API using curl commands. curl is a Linux shell command that generates HTTPS requests and is executed on an
external server.
curl Commands
curl command options include:
-X species the HTTPS request type; for example, POST , PATCH, or GET.
-u species the user name and password to use for server authentication.
-k species a text le to read curl arguments from. The command line arguments found in the text le will be used as if they were
provided on the command line. Use the IP address or URL of the OS10 switch when you access the OS10 RESTCONF API from a
remote orchestration system.
-H species an extra header to include in the request when sending HTTPS to a server. You can enter multiple extra headers.
-d sends the specied data in an HTTPS request.
In curl commands, use %2F to represent a backslash (/); for example, enter ethernet1/2/3 as ethernet1%2F1%2F3.
For more information, see the curl Man page.
Usage Information
Consider the following when accessing OS10 RESTSCONF API using curl commands:
The HTTPS request type; GET EVERYTHING can cause delay especially in a scaled system. It is recommended to use a specic URI of
the target resource to avoid any delay. For example,
curl -X GET -k -u admin:admin https://$TARGET/restconf/
data
When a RESTCONF query is in progress, you cannot congure any CLI commands until a RESTCONF query is complete.
It is recommended to use POST request instead of PUT, to replace the target data resources.
View XML structure of CLI commands
To use the RESTCONF API to congure and monitor an OS10 switch, create an HTTPS request with data parameters in JSON format. The
JSON data parameters correspond to the same parameters in the XML structure of an OS10 command.
To display the parameter values in the XML code of an OS10 command as reference, use the debug cli netconf command in EXEC
mode. In CONFIGURATION mode, use the do debug cli netconf command.
This command enables a CLI-to-XML display. At the prompt, enter the OS10 command of the XML request and the reply you need. To exit
the CLI-to-XML display, use the no debug cli netconf command.
RESTCONF API
1147