nerdexam
Cisco

200-901 · Question #214

Refer to the exhibit. A developer creates a Python script that queries Cisco Webex. When the script is executed, a 401 code is returned. After troubleshooting, the developer discovers that the…

The correct answer is D. header = {"Authorization" : "Bearer YOUR_TOKEN"}. To correct a 401 Unauthorized error when querying a REST API, the HTTP request header must use the Authorization field with the Bearer token scheme to properly authenticate the request.

Understanding and Using APIs

Question

Refer to the exhibit. A developer creates a Python script that queries Cisco Webex. When the script is executed, a 401 code is returned. After troubleshooting, the developer discovers that the service is missing privileges. Which change to the header in line 4 of the script results in the code 200?

Exhibit

200-901 question #214 exhibit

Options

  • Aheader = {"Authentication": "Bearer YOUR_TOKEN"}
  • Bheader = {"Authentication Bearer" : "YOUR_TOKEN"
  • Dheader = {"Authorization" : "Bearer YOUR_TOKEN"}

How the community answered

(39 responses)
  • A
    3% (1)
  • B
    10% (4)
  • D
    87% (34)

Why each option

To correct a 401 Unauthorized error when querying a REST API, the HTTP request header must use the `Authorization` field with the `Bearer` token scheme to properly authenticate the request.

Aheader = {"Authentication": "Bearer YOUR_TOKEN"}

The header key `Authentication` is not the standard HTTP header for sending bearer tokens; the correct header field is `Authorization`.

Bheader = {"Authentication Bearer" : "YOUR_TOKEN"

`Authentication Bearer` is not a valid HTTP header key; the standard is `Authorization` followed by the scheme and credentials.

Dheader = {"Authorization" : "Bearer YOUR_TOKEN"}Correct

A 401 Unauthorized error typically indicates missing or incorrect authentication credentials. The standard HTTP header for sending authentication tokens, especially bearer tokens, is `Authorization`, with the value formatted as `Bearer YOUR_TOKEN`. This correct header provides the necessary credentials for the API to grant access, leading to a 200 OK response if privileges are sufficient.

Concept tested: REST API authentication - HTTP Authorization header

Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization

Topics

#API Authentication#HTTP Headers#REST APIs#Webex API

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice