Bird
0
0

Given the API endpoint /products?filter=price>20&sort=price, what is the expected behavior?

medium📝 Predict Output Q13 of 15
Rest API - Query Parameters and Filtering
Given the API endpoint /products?filter=price>20&sort=price, what is the expected behavior?
AReturn products with price greater than 20, sorted by price ascending.
BReturn all products ignoring the filter and sort parameters.
CReturn products with price less than 20, sorted by price descending.
DCause a syntax error due to invalid query format.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the filter parameter

    The filter 'price>20' means select products priced above 20.
  2. Step 2: Analyze the sort parameter

    The sort 'price' means sort results by price in ascending order by default.
  3. Final Answer:

    Return products with price greater than 20, sorted by price ascending. -> Option A
  4. Quick Check:

    filter price>20 + sort price ascending = Return products with price greater than 20, sorted by price ascending. [OK]
Quick Trick: Filter narrows data; sort orders it [OK]
Common Mistakes:
MISTAKES
  • Confusing greater than with less than
  • Assuming sort defaults to descending
  • Thinking query causes syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes