Home > Use Postman to configure CSR1000v router on Cisco Sandbox with RESTCONF

Use Postman to configure CSR1000v router on Cisco Sandbox with RESTCONF

August 23rd, 2021 Go to comments

Postman and RESTCONF are two topics that we need to grasp in the ENCOR exam so in this tutorial we will learn the basis about them. In order to complete this tutorial, please download and install Postman first. This is a simple task so we will not mention it here.

After installing Postman, go to this Postman link and export the Cisco IOS-XE collection to a file on your local drive because we are going to communicate to a Cisco IOS XE router via Postman.

Postman_collection_export.jpg

Choose the latest version of Collection is better so we will choose “Collection v2.1”.

Postman_collection_export2.jpg

Now open Postman to import the collection by clicking on “Import” button:

Postman_import_collection.jpg

Choose the downloaded file to upload:

Postman_import_collection_upload_file.jpg

And now we have a list of RESTCONF APIs (commands) under “Cisco IOS-XE” collection to play with.

Postman_import_collection_success.jpg

But where will we send these commands to? It is nice that Cisco offers many free devices online to practice with in the DEVNET program. You can visit this link: https://devnetsandbox.cisco.com/RM/Topology and search for “IOS XE”. The website returns a list of labs but we should choose “IOS XE on CSR Latest …” (Always On) lab as we don’t have to wait to reserve and use it like other labs.

sandbox_devnet_search_IOS_XE.jpg

After accessing this lab, all the information we need is in the red box below. It tells us where to send our RESTful APIs in Postman to along with the username and password.

sandbox_devnet.jpg

Now return to our Postman, we will provide the username and password provided above to the “Basic Authentication”.

Postman_Basic_Authentication.jpg

In the “Type” drop-down box of “Auth” tab, choose “Basic Auth” and enter the username “developer” and password “C1sco12345” as provided in the Cisco sandbox website above.

Postman_Basic_Authentication_2.jpg

Set “Inherit auth from parent” for sub-category “RESTCONF” so that it will use the authentication information from parent node “Cisco IOS-XE”.

Postman_Inherit_Auth.jpg

In each RESTful API we are going to send, we also have to choose “Inherit auth from parent” too.

Postman_set_basic_Auth.jpg

Define variables

After setting the authentication, now we can have a closer look on the RESTCONF commands. When hovering mouse on {{host}} in the URL, we can see an “Unresolved Variable” popup. It means Postman has not learned how to interpret this {{host}} variable yet.

Postman_unresolved_variable.jpg

In order to define this variable, click on the eye icon at the top-right corner of Postman and choose either “Add” Environment or Globals.

Postman_add_Environment.jpg

Type “host” in the VARIABLE field to define this variable. In the INITIAL VALUE, copy the value “sandbox-iosxe-recomm-1.cisco.com” from the Cisco DEVNET website and paste here.

Same for “port” variable. Then don’t forget to click on “Save” button.

Postman_set_global_environment.jpg

After saving we will have a new environment with name “Cisco IOS XE”, select it.

set_new_environment.jpg

Now we see our {{host}} variable has been resolved by the green icon “E” when hovering on it:

set_new_environment2.jpg

Remember to change Auth Type from “Basic Authentication” to “Inherit auth from parent” for each request we are going to send, then click on “Save” to save all the settings for this request. Unfortunately, we have to save each command for the first time.

save_request.jpg

Click “Send” and wait for a few seconds then we will receive the reply, notice the returned code is “200 OK”. The command we sent is a “GET” command, which is equivalent to a “show” CLI command. In this case we sent a “GET” interface state on this router.

request_sent_success.jpg

After getting information of interfaces successfully, we can try some configuration on the remote device.

Create a Loopback interface

Choose “Add new loopback interface” in the command list. Check the URL carefully because some are configured in http by default so if we submit them they will fail. Please change them to https instead:

Post_http.jpg

Configure new Loopback interface information in the “Body” part with the following information:

+ name: Loopback101
+ ip: 143.1.1.1
+ netmask: 255.255.255.0

Keep other information unchanged, then click “Send”. We will see a “201 Created” reply.

Postman_add_Loopback.jpg

Delete a Loopback interface

Next we will delete the Loopback 101 we have just created. We just need to type “Loopback1o1” at the end of the command. If everything is correct, we will be replied with status “204 No Content”

Postman_delete_loopback101.jpg

Note: HTTP status code of 2xx means “Success”, which indicates that the client’s request was accepted successfully.

Comments
  1. No comments yet.
  1. No trackbacks yet.