200-901 Software Development and Design Practice Question
A developer is building a REST API client in Python using the requests library. They need to send a JSON payload with authentication. Which code snippet correctly sends a POST request with a JSON body and a Bearer token?
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.post(url, json=payload, headers={'Authorization': f'Bearer {token}'})
The correct way is to use json parameter for JSON body and headers for authorization.
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.post(url, data=payload, auth=token)
Why it's wrong here
auth is for basic auth, not Bearer.
- ✓
requests.post(url, json=payload, headers={'Authorization': f'Bearer {token}'})
Why this is correct
Correct: json= automatically sets content-type and serializes.
- ✗
requests.post(url, data=json.dumps(payload), headers={'Authorization': token})
Why it's wrong here
Missing 'Bearer' prefix.
- ✗
requests.post(url, params=payload, auth=('Bearer', token))
Why it's wrong here
params is for query string, not body.
Go deeper
Related to this question
About these practice questions
This 200-901 question is part of Courseiva's 989-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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.