200-901 Software Development and Design Practice Question
A Python script sends a POST request to create a new network device resource. The API returns HTTP status code 201 and a JSON response with the device ID. How should the script correctly extract the device ID from the response?
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
✓
device_id = response.json().get('id')
A 201 status indicates successful creation, and response.json() parses the JSON body into a Python dict.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
device_id = response['id']
Why it's wrong here
Response object is not subscriptable; must use .json() first.
- ✗
device_id = response.text['id']
Why it's wrong here
response.text is a string, not dict; cannot index with key directly.
- ✓
device_id = response.json().get('id')
Why this is correct
response.json() returns a dict; .get() safely retrieves the 'id' key.
- ✗
device_id = json.loads(response)['id']
Why it's wrong here
json.loads expects a string; response is a Response object, not a string.
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.