Bird
0
0

Which query parameter should you use to correctly request sparse fieldsets?

hard📝 Application Q15 of 15
Rest API - Advanced Patterns
You want to optimize a REST API call to fetch only the id, name, and email fields of users, but your API client library automatically encodes square brackets. Which query parameter should you use to correctly request sparse fieldsets?
Afields(users)=id,name,email
Bfields[users]=id,name,email
Cfields%5Busers%5D=id,name,email
Dfields-users=id,name,email
Step-by-Step Solution
Solution:
  1. Step 1: Understand URL encoding for brackets

    When the API client library automatically encodes square brackets in URLs, provide the raw form with literal square brackets. The client will properly encode them to %5B and %5D.
  2. Step 2: Match syntax with options

    fields[users]=id,name,email is the raw syntax to use, which the client encodes correctly to fields%5Busers%5D=id,name,email.
  3. Final Answer:

    fields%5Busers%5D=id,name,email -> Option C
  4. Quick Check:

    Raw brackets; client encodes to %5B%5D [OK]
Quick Trick: Use raw fields[resource]=...; client auto-encodes brackets [OK]
Common Mistakes:
MISTAKES
  • Pre-encoding brackets as %5B%5D (risks double-encoding)
  • Using parentheses instead of brackets
  • Replacing brackets with dashes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes