Skip to content

Commit 39d9633

Browse files
committed
Partial edits
1 parent 6c4472b commit 39d9633

File tree

15 files changed

+66
-89
lines changed

15 files changed

+66
-89
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

labs/coding-101-rest-basics-ga/1.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
This Learning Lab explains the basics of using a REST API. It also shows how to use Postman to explore a REST API.
55

6-
## Objective
6+
## Objectives
77

88
* Understand REST APIs
99
* Learn how to use the Postman application to make API calls
@@ -23,15 +23,15 @@ This Learning Lab explains the basics of using a REST API. It also shows how to
2323
A good starting point to understand any API is to look at the documentation for the API. Now, find documentation for the DNA Center API.
2424

2525
1. In a browser, navigate to the [DevNet](https://developer.cisco.com/) home page.
26-
1. Use the menu at the top to navigate to the .
26+
1. Use the menu at the top to navigate to the DNA Center Platform page.
2727
* Click the **Technologies** link to see the submenu.
28-
* Click **Networking**
29-
* From the list of technologies, click **DNA Center Platform)**.
28+
* Click **Networking**.
29+
* From the list of technologies, click **DNA Center Platform**.
3030
![](/posts/files/coding-101-rest-basics-ga/assets/images/Menu.png)
31-
<br/>
31+
3232
1. On the DNA Center Platform page, click the `Docs` link.
3333
1. Click `API Reference`.
3434
1. Select the latest API version.
35-
1. Keep the DNA Center API Reference documentation open in a separate tab. This will be a useful reference while you work on this lab.
35+
1. Keep the DNA Center API Reference documentation open in a separate tab. This page provides a useful reference while you work on this lab.
3636

37-
### Next Step: Learn about the REST Web Service
37+
### Next Step: Learn about the REST web service

labs/coding-101-rest-basics-ga/2.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Using the DNA Center APIs, you can retrieve information about devices on your ne
2828

2929
Look at the [DNA Center documentation](https://developer.cisco.com/site/dna-center-rest-api/) to see the details of the functions.
3030

31-
3231
### How does this work?
3332

3433
![](/posts/files/coding-101-rest-basics-ga/assets/images/howitworks.jpg "How it Works")
@@ -37,7 +36,7 @@ REST is centered around the HTTP request and response model. Consuming an API is
3736

3837
In this example, you request the list of hosts, and that information is returned to you in the response. The data returned in the response is usually formatted as JSON or XML.
3938

40-
* [JSON](https://www.json.org/") - JSON, or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange.
39+
* [JSON](https://www.json.org/) - JSON, or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange.
4140

4241
* [XML](https://www.w3schools.com/xml/xml_whatis.asp) - XML, or eXtensible Markup Language, a language designed to store and transport data.
4342

labs/coding-101-rest-basics-ga/3.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,26 @@ REST APIs have three common methods to authenticate users:
3232

3333
* **Basic HTTP:** The username and password are passed to the server as an encoded string. For more information, see [Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication).
3434
* **OAuth:** Open standard for HTTP authentication and session management. Creates an access token associated with a specific user that also specifies the user rights. The token identifies the user and rights when making API calls to verify access and control. See [OAuth](https://en.wikipedia.org/wiki/OAuth) for more information.
35-
3. **Token:** As with OAuth, a token is created and passed with each API call, but there is no session management and tracking of clients. This simplifies interaction between the server and client. APIC-EM uses this design for authentication management. See [Token Based Authentication](https://scotch.io/tutorials/the-ins-and-outs-of-token-based-authentication) for more information.
35+
3. **Token:** As with OAuth, a token is created and passed with each API call, but there is no session management and tracking of clients. This simplifies interaction between the server and client. See [Token Based Authentication](https://scotch.io/tutorials/the-ins-and-outs-of-token-based-authentication) for more information.
3636

37-
APIC-EM uses token-based authentication. So the first request you need to make creates a token. In APIC-EM, this token is called a *token*. The controller uses the token to determine which endpoints you can access. The token must be included in every API call except the one that creates the ticket.
37+
APIC-EM uses token-based authentication. So the first request you need to make creates a token. In DNA Center, this string is called a *token*. The controller uses the token to determine which endpoints you can access. The token must be included in every API call.
3838

39-
The steps for using the APIC-EM authentication token are:
39+
The steps for using the DNA Center authentication token are:
4040

41-
1. Create a ticket
41+
1. Send a POST to the token endpoint.
4242
2. A ticket (token) is returned in response body.
4343
3. Include this token in the 'X-Auth-Token' header on all subsequent requests.
4444

4545
### Using the API Reference Documentation
4646

47-
The API Reference Documentation is where you can find the list of the API methods and the details for information on how to make each request. When you are starting to work with a new API,
48-
the API Reference is one of the most important sources of information.
47+
The API Reference Documentation is where you can find the list of the API methods and the details for information on how to make each request. When you are starting to work with a new API, the API Reference is one of the most important sources of information.
4948

5049
Study the Ticket API in APIC-EM:
5150

52-
* Open the <a href="https://developer.cisco.com/site/apic-em/docs/api.html?version=1.6" target="_blank">APIC-EM Reference Docs</a>. Pick the proper version of API. The entire API is presented in scrollable format.
51+
* Open the [DNA Center API reference docs](https://developer.cisco.com/site/dna-center-rest-api/). Pick the proper version of API. The entire API is presented in scrollable format.
5352

5453
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide1.png)
5554

56-
* Click **Roll Based Access Control**, then scroll down to **ticket**.
57-
58-
* Click **'POST' /ticket**. This endpoint provides functionality to create a ticket.
59-
6055
* The API Reference includes attributes to be sent and returned. The Response portion defines the returned data, including HTTP status codes.
6156

6257
* HTTP status codes indicate success, error, or other conditions. For more information, see [https://www.w3.org/Protocols/HTTP/HTRESP.html](https://www.w3.org/Protocols/HTTP/HTRESP.html)
@@ -66,15 +61,12 @@ Study the Ticket API in APIC-EM:
6661
* 401 Not Authorized
6762

6863

69-
* Review the content to see what data is expected to be sent to the server and returned to your application. Both are circled here. In the example response for the Create Ticket request, you can see that the response string contains a `serviceTicket` attribute with a value of type string. This value is the authentication token you will need to make calls to all of the other API endpoints.
64+
* Review the content to see what data is expected to be sent to the server and returned to your application. In the example response for the network devices request, you can see that the response string contains a `hostName` attribute with a value of type Array[string].
7065

7166
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide4.png)
7267

73-
* In the Parameters section, click **Example Value**. Double-clicking the box moves the parameters to an editable box on the left to try out the function.
74-
75-
![](/posts/files/coding-101-rest-basics-ga/assets/images/refguide5.png)
68+
### Things to try
7669

77-
### Things to Try
78-
* Look at the other ticket endpoints in the API Reference Guide. How do they differ from one another?
70+
* Look at the other network devices endpoints in the API Reference Guide. How do they differ from one another?
7971

80-
### Next Step: Make HTTP calls Using REST
72+
### Next Step: Make HTTP calls using REST

labs/coding-101-rest-basics-ga/4.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Step 4. Constructing a REST Call
1+
## Step 4. Construct a REST Call
22

3-
### APIC-EM Example: POST Create a Ticket
3+
### DNA Center Example: POST Create a Token
44

55
Now, look at how to use the API to create a token for authentication.
66

@@ -12,39 +12,28 @@ You need to know how to construct the request to retrieve the token. Use the API
1212
* Authentication
1313
* Body
1414

15-
All of the URLs for APIC-EM begin with:
16-
17-
```http
18-
19-
https://{APIC-EM-Server}/api/v1
20-
21-
```
22-
23-
Get the description of the ticket API call from the -- <a href="https://developer.cisco.com/site/apic-em/docs/api.html?version=1.6" target="_blank">DNA Center API Docs</a>. Choose the proper API version.
24-
25-
`POST /api/v1/ticket`: This method creates a new user ticket
15+
Get the description of the token API call from the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api/). Choose the proper API version.
2616

17+
`POST /api/v1/token`: This method creates a new user token.
2718

2819
The HTTP call to a create a token is easy.
29-
```http
20+
```
3021
31-
https://{APIC-EM-Server}/api/v1/ticket
22+
POST https://{DNA-Center-Server}/api/system/v1/auth/token
3223
3324
```
3425

3526
To get the token your request will look like this:
3627

3728
* **Method** - `POST`
38-
* **URL** - `https://{APIC-EM-Server}/api/v1/ticket`
39-
* Substitute `{APIC-EM-Server}` with the IP address or hostname of the DNA Center you are using. For example, the Cisco DevNet Learning Labs DNA Center is `https://sandboxdnac.cisco.com/`.
29+
* **URL** - `https://{DNA-Center-Server}/api/system/v1/auth/token`
30+
* Substitute `{DNA-Center-Server}` with the IP address or hostname of the DNA Center you are using. For example, the Cisco DevNet Learning Labs DNA Center is `https://sandboxdnac.cisco.com/`.
4031
* **Headers**
4132
* Specify the 'Content-Type' as 'application/json'. It's typical to include this header with all HTTP methods (GET, POST, PUT, DELETE) calls.
4233
* **Authentication**
4334
* In this API call, the authentication data is passed in the body.
4435
* **Body**
4536
* Provide the username and password for logging into the DNA Center in JSON format.
4637

47-
![](/posts/files/coding-101-rest-basics-ga/assets/images/apic-em-request.png)
48-
4938

50-
### Next Step: Making a REST API Call
39+
### Next Step: Making a REST API call

labs/coding-101-rest-basics-ga/5.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ On OS X, to use Python 3.4, you may need to accept the SSL certificate before ca
2222

2323
4. Click the **Proceed to &lt;your IP>** link.
2424

25-
5. You should then be taken the login screen. Now you are ready to start working in Postman.<br/><br/>
26-
![](/posts/files/coding-101-rest-basics-ga/assets/images/ssl3.png)
25+
5. You should then be taken the login screen. Now you are ready to start working in Postman.
2726

28-
### Using Postman to make REST API Calls
27+
### Use Postman to make REST API calls
2928

3029
1. Start Chrome and open Postman. If you are on a DevNet Zone station, Postman is already installed.
3130

32-
2. For your request to retrieve the list of hosts into the appropriate Postman fields, enter the following information:
31+
2. Set up your request to retrieve a token. In the Postman fields, enter the following information:
3332

3433
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman1.png)
3534

@@ -38,17 +37,21 @@ On OS X, to use Python 3.4, you may need to accept the SSL certificate before ca
3837
* **URL**
3938
* ``B.`` Enter `https://sandboxdnac.cisco.com/api/system/v1/auth/token` to use the DevNet Sandbox, or enter your own API endpoint.
4039
* **Body**
41-
* ``C.`` Enter the username and password in JSON format. These credentials are used to log into the DNA Center. If you are accessing the DNA Center Platform Sandbox, enter the username and password, as specified earlier. Otherwise, enter the required username and password for your DNA Center.
40+
* ``C.`` Enter the username and password in JSON format. Use these credentials to get a token for use in the DNA Center. If you are accessing the DNA Center Platform Sandbox, enter the username and password, as specified earlier. Otherwise, enter the required username and password for your DNA Center.
4241
* **Headers**
43-
* ``A.`` In the header, enter: `Content-Type` followed by `application/json`.<br/><br/>
44-
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman2.png)<br/><br/>
45-
* **Authentication**
46-
* Authentication is entered using the Body, as specified earlier.
42+
* ``A.`` In the header, enter: `Content-Type` followed by `application/json`.
4743
3. Click **Send**.
4844
4. Postman sends the request to the server and displays the response.
4945
* The **Response Code**, `200`, appears in the **Status** field.
50-
* The **JSON** response contains a **token** attribute. You've highlighted an example token value. The actual value will be different. **Copy and paste this value into a text file to use for the next steps!**
46+
* The **JSON** response contains a **token** attribute. Here is an example token value. The actual value will be different.
5147

52-
#### Congratulations! You made your first REST API call!
48+
```
49+
{
50+
"Token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1YjE1MGMwMzY1MWY5MzAwOGFjZDEzZGIiLCJhdXRoU291cmNlIjoiaW50ZXJuYWwiLCJ0ZW5hbnROYW1lIjoiVE5UMCIsInJvbGVzIjpbIjViMTNmY2ZhNjUxZjkzMDA4YWNkMDcwOSJdLCJ0ZW5hbnRJZCI6IjViMTNmY2Y5NjUxZjkzMDA4YWNkMDcwMiIsImV4cCI6MTUyODg0MTE1OCwidXNlcm5hbWUiOiJkZXZuZXR1c2VyIn0.rK54CBNlua7AjRT7rtWIV6jzpGTNK7OUTs10t8MDGoF"
51+
}
52+
```
53+
**Copy and paste this value into a text file to use for the next steps!**
54+
55+
#### Congratulations! You made a first REST API call to DNA Center!
5356

5457
### Next Step: Hosts API URL

labs/coding-101-rest-basics-ga/6.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,47 @@
1-
## Step 6. Using the Service Ticket to Make APIC-EM REST API Calls
1+
## Step 6. Use a token to make REST API calls
22

3-
### APIC-EM Example: Get Hosts
3+
### Example: Get Hosts
44

55
Now, look at the Get Hosts endpoint. A host is an end device attached to the network, such as a computer connected to a wireless device. Your goal is to find the hosts and display information about them.
66

7-
To construct a request that retrieves a list of hosts, refer to the <a href="https://developer.cisco.com/site/apic-em-rest-api//" target="_blank">DNA Center API Docs</a>. Click on Inventory under Services to find Get /host. These provide the following information:
7+
To construct a request that retrieves a list of hosts, refer to the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api/). Click on Inventory under Services to find Get /host. These provide the following information:
88

99
* Method
1010
* URL
1111
* Headers
1212
* Authentication
1313
* Body
1414

15-
As specified earlier, you can see that the base URL for APIC-EM is:
16-
17-
```http
18-
19-
https://{APIC-EM-Server}/api/v1
15+
As specified earlier, you can see that the base URL for DNA Center is:
2016

17+
```
18+
https://{DNA-Center-Server}/api/v1
2119
```
2220

2321
The following call retrieves all of hosts on the specified server
24-
```http
25-
26-
GET https://{APIC-EM-Server}/api/v1/host
2722

23+
```
24+
GET https://{DNA-Center-Server}/api/v1/host
2825
```
2926

3027
Alternatively, you may want to retrieve some of the hosts to page through them. In that case, pass the 'limit' parameter to specify the maximum number of hosts to be returned. You can also pass the 'offset' parameter to specify where to start the list of hosts. The following call specifies to start from the first host, (offset=1), and to return a maximum of five hosts, (limit=5).
31-
```http
32-
33-
GET https://{APIC-EM-Server}/api/v1/host?limit=5&offset=1
34-
28+
```
29+
GET https://{DNA-Center-Server}/api/v1/host?limit=5&offset=1
3530
```
3631

37-
To get the entire list of hosts, your request will be like this:
32+
To get the entire list of hosts, your request contains these items:
3833

3934
* **Method** - `GET`
40-
* **URL** - `https://{APIC-EM-Server}/api/v1/host`
35+
* **URL** - `https://{DNA-Center-Server}/api/v1/host`
4136
* Insert the IP address or hostname of the DNA Center.
4237
* **Headers**
43-
* For authentication, add the token that was created earlier. On the left side of the header, add the text 'X-Auth-Token'. On the right side, add the token value. See screenshot on next page for information on how to set this up in Postman.
44-
* When using GET, a content header is not required. However, it's a good practice to specify the content in the header anyway as 'Content-Type' 'application/json'.
38+
* For authentication, add the token that was created earlier. On the left side of the header, add the text 'X-Auth-Token'. On the right side, add the token value.
39+
* When using GET, a content header is not required. However, it's a good practice to specify the content in the header anyway as: 'Content-Type' 'application/json'.
4540
* **Authentication**
4641
* Handled in the header.
4742
* **Body**
4843
* Not required for this request.
4944

50-
![](/posts/files/coding-101-rest-basics-ga/assets/images/apic-emHostRequest.png "Get Hosts")
51-
<br/>
52-
<br/>
45+
![](/posts/files/coding-101-rest-basics-ga/assets/images/HostRequest.png)
5346

5447
### Next Step: Get Network Hosts

labs/coding-101-rest-basics-ga/7.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
## Step 7. Getting the Network Hosts
22

33
1. Set up the API call in Postman.
4-
* Now, use the token to authorize a request to GET the hosts from the controller.<br/><br/>
5-
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman4.png)<br/><br/>
4+
* Now, use the token to authorize a request to GET the hosts from the controller.
5+
![](/posts/files/coding-101-rest-basics-ga/assets/images/postman4.png)
66

77
2. Enter the following information:
88
* **Method**
9-
* `A.` Select **GET** in the Method drop down
9+
* `A.` Select **GET** in the Method drop down.
1010
* **URL**
11-
* `B.` Enter **https://sandboxdnac/api/v1/host**
11+
* `B.` Enter **https://sandboxdnac.cisco.com/api/v1/host**
1212
* If you are not using your DNA Center, use the DNA Center Lab: https://sandboxdnac.cisco.com.
1313
* **Headers**
14-
* `C.` Enter the 'Content-Type' and value 'application/json'
14+
* `C.` Enter the 'Content-Type' and value 'application/json'.
1515
* `C.` Enter the 'X-Auth-Token' and the token created earlier. The 'X-Auth-Token' is required for all DNA Center API calls.
1616
* **Authentication**
1717
* Handled in the Headers

labs/coding-101-rest-basics-ga/8.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Now, look at the Get Network Devices endpoint. A Network Device transports data to/from host devices or other network devices. A network device is typically a hub, switch, or router. It can be connected to the network by an Ethernet cable or wireless connection. Your goal is to find the network devices and display information about them.
44

5-
For details about the Get Network Device API, consult the [DNA Center API Docs](https://developer.cisco.com/site/apic-em-rest-api//).
5+
For details about the Get Network Device API, consult the [DNA Center API Docs](https://developer.cisco.com/site/dna-center-rest-api//).
66

77
1. Set up the API Call in Postman. Use the token to authorize a request to GET the network devices from the controller.
88

Loading

0 commit comments

Comments
 (0)