Bird
0
0

You want to filter a list of events to show only those happening in 2024 and located in either 'New York' or 'Los Angeles'. Which query parameter format correctly expresses this filter?

hard📝 Application Q15 of 15
Rest API - URL and Resource Design

You want to filter a list of events to show only those happening in 2024 and located in either 'New York' or 'Los Angeles'. Which query parameter format correctly expresses this filter?

Aapi/events?year=2024&city=New York,Los Angeles
Bapi/events?year=2024&city=New%20York&city=Los%20Angeles
Capi/events?year=2024&city=New York&city=Los Angeles
Dapi/events?year=2024&city=New%20York|Los%20Angeles
Step-by-Step Solution
Solution:
  1. Step 1: Understand filtering multiple values for one parameter

    To filter by multiple cities, repeat the parameter with URL-encoded values.
  2. Step 2: Check URL encoding and parameter repetition

    api/events?year=2024&city=New%20York&city=Los%20Angeles repeats 'city' with URL-encoded spaces, which is standard practice.
  3. Final Answer:

    api/events?year=2024&city=New%20York&city=Los%20Angeles -> Option B
  4. Quick Check:

    Repeat parameters with URL encoding for multiple values [OK]
Quick Trick: Repeat parameter with encoded values for multiple filters [OK]
Common Mistakes:
  • Using commas without encoding or server support
  • Not encoding spaces in city names
  • Using '|' which is not standard in URLs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes