CCNA DEVASC M2 – Application Programming Interfaces

1. It is a set of rules that allows programs to converse with each other.
The developer creates this on the server and allows the client to talk to the server.
2. Which of these REST API request methods does not change the status of the resource ?
3. What type of documentation should you review when sending a request to an API?
4. So let's say you are trying to send a GET request to an API, however when you send the request you get an HTTP response code of 404.

The request method seems correct. What does this mean and whats wrong with your request?
5. Given this information from the API documentation:

Request Method: GET
Server: localhost:5000
Resource: /api/v1.0/device?hostname=DEVNET-RTR-01

When you send a request that aligns to the API Documentation, what does this return?
6. Can you spot what is wrong with this API request using python?

*API Documentation:

Request Method: GET
Server: localhost:5000
Resource: /api/v1.0/device

*Python Request syntax

response = requests.request("GET"http://localhost:5000/api/v1.0/device")
7. You sent a GET request to an API resource and receive status code of 200 .

However when you check the body of the response, it only shows "[]" .

What does this mean?

 

 
8. Referring to the illustration below, when you send a POST request to an API, what does the "JSON" field setting mean?

9. What does this snippet do in a python code to communicate to an API?

headers = {  'Content-Type': 'application/json'}
10. When sending a API Request using python, you noticed that you are receiving an error after sending this syntax below.

response = requests.request("POST", "http://localhost:5000/api/v1.0/add", headers=headers, data = json_data_1)You reviewed the API documentation and it seems the request method and resources are correct.

So assuming that this syntax is correct , what are the other potential issues in the python script? (Choose 2)
11. Which syntax in python code returns the HTTP response codes after sending the API request?
12. Say you want to update the status of an interface of a certain device.

Which request method should you use to accomplish it?
13. What does this JSON data do when you send it via PUT request method?

14. You are sending a PUT request using python , identify what is missing on the blanks below.

import requests

response = _______._______("PUT",”http://localhost:5000/api/v1.0/DEVNET-RTR-01/1/unshutdown”)
15. On this script below, what does the syntax in the red box mean?

16. This refers to tools that allow you to react to events and changes in an application.

What is this?
17. Webhooks are analogous to the "push effect" . (True or False)?
18. In Webhooks, the route holding the logic has to be accessible through an HTTP _________ request .
19. What is the first step in subscribing to a webhook?
20. Which of these options refer to the key constraints of an API?

Choose all that applies.
21. In this API constraint, the target resource is down, the request can be routed to another backup resource and the requester doesn't need to know.

What is this?
22. The system constraint allows the architect to inject services between the server and the client in order to efficiently serve the client request while the layering remains transparent to the client.
23. This constraint allows the web to deal with the massive scale of the internet.

What is it?
24. This constraint allows the server to send the code to the client in the form of scripts and applets.

What is it?
25. This HTTP response code indicates that the client’s request was accepted successfully
26. This HTTP response code points the issue to the client.
What is it?
27. This HTTP response code points the issue to the server.
What is it?
28. This error status code indicates that the REST API can't map the client's URI to a resource but may be available in the future.
29. This is  the generic client-side error status, used when no other 4xx error code is appropriate.
30. A REST API responds with the this status code whenever a resource is created inside a collection.
31. This response code is typically used for actions that take a long while to process.
It indicates that the request has been accepted for processing, but the processing has not been completed.
32. This error response code is the generic REST API error response.
Most web frameworks automatically respond with this response status code whenever they execute some request handler code that raises an exception.
33. This error response code is returned when the server either does not recognize the request method, or it cannot fulfill the request.
34. You recently run a python script to send a request to an API however you received this error response code and error comments.

What should you check to fix it?

 
35. You are trying to send a request using this python code:

########

import requests
from requests.auth import HTTPBasicAuth

response = requests.get("http://localhost:5000/api/v2.0/device",auth=HTTPBasicAuth('cisco', 'cisco'))
print(response.text)
print("Status Code: {}".format(response.status_code))
####
However after sending the request, you received an error status code of 401.

What does this mean?

 

 
36. It is an API development environment that allows you to test, debug, monitor, document, and publish your APIs.

what is it?
37. It is the part of an HTTP request which includes the target server and target resource of the API.

What is it?
38. It is the part of an HTTP request which will inform the API that the request will send data in JSON form.

What is it?
39. It is the part of an HTTP request where you can specify if you want to send a POST, GET, PUT or DELETE request.

What is it?
40. It is the part of an HTTP response that shows if the request has an error or if it is successful?

What is it?
41. You are able to successfully send a GET request to an API resource after adding the username and password in the request.

Now you are trying to send another GET request for another API resource however this request is failing . What should you do?
42. On this kind of API style, it only uses GET and POST while you need to review the resource to actually understand what it will do to the API.

Which API style is this?
43. On this kind of API style,  you expose data as resources that you manipulate through HTTP protocol using the right HTTP verb .

Which API style is this?
44. The design of this API needs the designers to be strict to achieve a consistent API as you do not really have constraints.
45. Which API style does this syntax represent?

GET (or POST) /deleteItem?itemId=456
46. Which API style does this syntax represent?

DELETE /users/1234
47. In this API call, it means that code execution will block (or wait) for the API call to return before continuing.

This means that until a response is returned by the API, your application will not execute any further, which could be perceived by the user as latency or performance lag in your app
48. These calls do not block (or wait) for the API call to return from the server.

Execution continues on your program, and when the call returns from the server, a "callback" function is executed
49. I have a "C" language program with a "print()" function.

I've coded "PrintHP()" and "PrintCanon()" to spawn threads to do the I/O to the physical printer.

"Print()" exits as soon as the thread is created; the actual "printing" goes on in parallel with program execution.

Which API call does this represent?
50. These calls do not block (or wait) for the API call to return from the server. Execution continues on in your program, and when the call returns from the server, a "callback" function is executed

 

Leave a comment