Bird
0
0

How would you modify the request /employees?sort=age to sort by age ascending but only include employees with age greater than 30?

hard📝 Application Q9 of 15
Rest API - Query Parameters and Filtering
How would you modify the request /employees?sort=age to sort by age ascending but only include employees with age greater than 30?
A/employees?sort=age&age>30
B/employees?sort=age&filter=age>30
C/employees?sort=age>30
D/employees?filter=age>30&order=age
Step-by-Step Solution
Solution:
  1. Step 1: Separate sorting and filtering parameters

    Sorting uses sort=age, filtering uses a separate filter parameter.
  2. Step 2: Use correct filter syntax

    filter=age>30 filters employees older than 30.
  3. Final Answer:

    /employees?sort=age&filter=age>30 -> Option B
  4. Quick Check:

    Sort and filter are separate query parameters [OK]
Quick Trick: Use separate filter parameter for conditions [OK]
Common Mistakes:
  • Combining sort and filter in one parameter
  • Using invalid syntax like 'age>30' alone
  • Using 'order' instead of 'sort'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes