Bird
0
0

You want to design a REST API that returns a list of users with optional filtering by age and supports pagination. Which advanced pattern combination best solves this real problem?

hard📝 Application Q15 of 15
Rest API - Advanced Patterns
You want to design a REST API that returns a list of users with optional filtering by age and supports pagination. Which advanced pattern combination best solves this real problem?
AUse POST method to send filters in the body and ignore pagination.
BUse query parameters for filters and pagination, and return consistent error messages.
CReturn all users in one response without filters or pagination.
DSend filters as headers and paginate by splitting responses manually.
Step-by-Step Solution
Solution:
  1. Step 1: Identify best practices for filtering and pagination

    Filters are commonly passed as query parameters; pagination also uses query parameters for page and size.
  2. Step 2: Combine with consistent error handling

    Returning consistent error messages helps clients handle issues gracefully.
  3. Final Answer:

    Use query parameters for filters and pagination, and return consistent error messages. -> Option B
  4. Quick Check:

    Filters + pagination via query params + consistent errors = Use query parameters for filters and pagination, and return consistent error messages. [OK]
Quick Trick: Use query params for filters and pagination [OK]
Common Mistakes:
MISTAKES
  • Ignoring pagination causing large responses
  • Using POST instead of GET for filtering
  • Sending filters in headers which is non-standard

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes