Courseiva

200-901 Software Development and Design Practice Question

A developer is reviewing a Python script that makes a REST API call using the requests library. The script must set a custom HTTP header 'X-Auth-Token' with a value from an environment variable. Which code snippet correctly adds this header to the request?

⚠ Common exam trap

Many exam-takers confuse the auth parameter, which is for HTTP Basic Authentication, with the headers parameter, which is used for arbitrary custom headers like API tokens.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

requests.get(url, headers={'X-Auth-Token': os.environ['TOKEN']})

The requests library accepts a headers parameter as a dictionary to set custom HTTP headers. Passing {'X-Auth-Token': os.environ['TOKEN']} correctly adds the token header while keeping the secret out of source code. The auth parameter is for basic authentication, params adds query strings, and data sets the request body, none of which fulfill the need for a custom header.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    requests.get(url, auth=('X-Auth-Token', os.environ['TOKEN']))

    Why it's wrong here

    The auth parameter is used for HTTP Basic Authentication, which sends credentials in the Authorization header, not for arbitrary custom headers. Using it here would not set X-Auth-Token and would incorrectly attempt basic auth with the token as a password, failing the scenario's requirement.

  • ✗

    requests.get(url, params={'X-Auth-Token': os.environ['TOKEN']})

    Why it's wrong here

    The params argument appends query string parameters to the URL, not HTTP headers. This would expose the token in the URL and not satisfy the requirement to set a header. Query parameters are visible in logs and browser history, making this approach insecure and incorrect for authentication tokens.

  • ✓

    requests.get(url, headers={'X-Auth-Token': os.environ['TOKEN']})

    Why this is correct

    This snippet passes the headers parameter as a dictionary, which is the correct way to set custom HTTP headers in the requests library. It reads the token from the environment variable TOKEN, satisfying the requirement without hardcoding secrets, and uses the standard get method with the url.

  • ✗

    requests.get(url, data={'X-Auth-Token': os.environ['TOKEN']})

    Why it's wrong here

    The data parameter is used to send a request body, typically for POST requests. A GET request with a body is unusual and not standard; the token would not be sent as a header. This fails to meet the requirement and may cause the server to ignore the body entirely.

About these practice questions

This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Cisco exam blueprint

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.