200-901 Software Development and Design Practice Question
A developer needs to create a Python script that makes a GET request to a REST API to retrieve a list of network devices. The API uses query parameters to filter by device type and status. Which TWO code snippets correctly include query parameters using the requests library? (Choose two.)
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('https://api.example.com/devices', params={'type': 'router', 'status': 'active'})
Option A is correct because requests.get() accepts a params dictionary, which the requests library automatically URL-encodes and appends to the URL as query parameters (e.g., ?type=router&status=active). Option C is correct because the query parameters are already embedded directly in the URL string after the ? character, separated by &, which is the standard HTTP way to pass query parameters on a GET request. Option B is incorrect because the data parameter sends a form-encoded body, which is not used for GET query parameters and would not appear in the URL. Option D is incorrect because the json parameter serializes the dictionary into a JSON request body, not query parameters. Option E is incorrect because the headers parameter sets HTTP request headers, not URL query parameters.
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('https://api.example.com/devices', params={'type': 'router', 'status': 'active'})
Why this is correct
Passing a dictionary to the `params` argument lets the requests library serialise the key-value pairs into a properly URL-encoded query string, appending `?type=router&status=active` to the endpoint. This satisfies the stem's requirement to filter by device type and status without manual string concatenation or encoding errors.
- ✗
requests.get('https://api.example.com/devices', data={'type': 'router', 'status': 'active'})
Why it's wrong here
Passing a dict to data sends it in the request body as form-encoded content, which a GET request does not use for filtering; query parameters require the params argument. The data argument is intended for POST, PUT or PATCH payloads, so it would be correct when submitting form fields rather than filtering a GET.
- ✓
requests.get('https://api.example.com/devices?type=router&status=active')
Why this is correct
Passing the parameters directly in the URL string satisfies the filtering constraint, since the query string `?type=router&status=active` is already URL-encoded and appended to the endpoint. The requests library sends this verbatim, so the API receives both device type and status filters without needing the `params` argument.
- ✗
requests.get('https://api.example.com/devices', json={'type': 'router', 'status': 'active'})
Why it's wrong here
The json argument serialises the dict into a JSON request body, which GET requests do not use for filtering; query parameters must be passed via params. The json argument is intended for POST, PUT or PATCH requests that submit a JSON payload, so it would be correct when creating or updating a resource.
- ✗
requests.get('https://api.example.com/devices', headers={'type': 'router', 'status': 'active'})
Why it's wrong here
The requests library sends headers as HTTP metadata, not URL query parameters, so the API receives no type or status filter. Headers carry authentication tokens, content negotiation and custom metadata; query parameters belong in the params argument or embedded in the URL string.
Go deeper
Related to this question
About these practice questions
One of 975 original 200-901 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.