200-901 Question 38
Single answerYou are tasked with creating a REST API request to retrieve a list of all devices from a network management system. According to the API documentation, the endpoint for fetching devices is /api/v1/devices, and it requires an HTTP GET method. Additionally, you must include an Authorization header with a bearer token for authentication. Which of the following is the correct API request to accomplish this?
- A
GET /api/v1/devices HTTP/1.1\nAuthorization: Bearer <your_token>
- B
POST /api/v1/devices HTTP/1.1\nAuthorization: Bearer <your_token>
- C
GET /api/v1/devices HTTP/1.1\nContent-Type: application/json
- D
GET /api/v1/devices HTTP/1.1\nAuthorization: Basic <your_token>
Show answer and explanation
Correct answer: A
Explanation
The correct API request uses the GET method to retrieve data, includes the correct endpoint /api/v1/devices, and specifies the Authorization header with a bearer token for authentication. The other options either use the wrong HTTP method, incorrect header, or lack necessary authentication.
- A. Correct.
Correct. The HTTP
GETmethod is specified in the API documentation, and theAuthorizationheader with a bearer token is required for authentication. - B. Incorrect.
Incorrect. The HTTP
POSTmethod is used for creating or modifying resources, not retrieving data. - C. Incorrect.
Incorrect. While the HTTP
GETmethod is correct, theContent-Typeheader is irrelevant for aGETrequest, and the requiredAuthorizationheader is missing. - D. Incorrect.
Incorrect. The
Authorizationheader must use a bearer token, not basic authentication, as specified in the documentation.