300-435 Question 37
Single answerA network engineer is tasked with automating a process to retrieve device information from Cisco DNA Center using its REST API. The engineer must authenticate with the API and then perform a GET request to fetch the devices. Which sequence of steps should the engineer follow to successfully complete this task?
- A
Send a GET request to the '/dna/system/api/v1/auth/token' endpoint to retrieve the token, then use the token to perform a GET request to the '/dna/intent/api/v1/network-device' endpoint.
- B
Perform a POST request with the username and password to the '/dna/system/api/v1/auth/token' endpoint, retrieve the token, and then use the token in the Authorization header for a GET request to '/dna/intent/api/v1/network-device'.
- C
Directly perform a GET request to the '/dna/intent/api/v1/network-device' endpoint with the username and password in the header.
- D
Retrieve the token by performing a GET request to the '/dna/intent/api/v1/network-device' endpoint, and then perform another GET request to the same endpoint with the token included.
Show answer and explanation
Correct answer: B
Explanation
To interact with Cisco DNA Center's REST API, the client must first authenticate by sending a POST request with their credentials to the '/dna/system/api/v1/auth/token' endpoint. This provides a token that must be included in the Authorization header for all subsequent API requests, such as retrieving device information from the '/dna/intent/api/v1/network-device' endpoint. Skipping or misordering these steps will result in authentication errors.
- A. Incorrect.
This is incorrect because a GET request cannot be used to retrieve the authentication token; it requires a POST request with the username and password.
- B. Correct.
This is the correct sequence. Cisco DNA Center's API requires the client to authenticate by sending a POST request with credentials to the '/dna/system/api/v1/auth/token' endpoint. The retrieved token is then used in the Authorization header to access other endpoints like '/dna/intent/api/v1/network-device'.
- C. Incorrect.
This is incorrect because the API does not allow direct access to the '/dna/intent/api/v1/network-device' endpoint using the username and password in the header. Authentication via token is required.
- D. Incorrect.
This is incorrect because the token cannot be retrieved from the '/dna/intent/api/v1/network-device' endpoint. Tokens are retrieved from the '/dna/system/api/v1/auth/token' endpoint.