Bird
0
0

A REST API returns JSON data for a list of users. You want to add a filter so the API only returns users older than 30. How should you design the API call?

hard📝 Application Q9 of 15
Rest API - REST API Fundamentals
A REST API returns JSON data for a list of users. You want to add a filter so the API only returns users older than 30. How should you design the API call?
ASend the age filter in the request body of a GET request
BUse a query parameter like /users?age_gt=30
CUse a POST request to /users with age filter in URL
DDelete users younger than 30 before calling the API
Step-by-Step Solution
Solution:
  1. Step 1: Understand REST filtering conventions

    Filters are usually sent as query parameters in the URL for GET requests.
  2. Step 2: Evaluate options

    Use a query parameter like /users?age_gt=30 correctly uses a query parameter. Others misuse HTTP methods or request body.
  3. Final Answer:

    Use a query parameter like /users?age_gt=30 -> Option B
  4. Quick Check:

    Filters in REST = Query parameters [OK]
Quick Trick: Use URL query parameters to filter REST API data [OK]
Common Mistakes:
  • Sending body data in GET requests
  • Using POST for data retrieval
  • Trying to delete data before filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes