Bird
0
0

You wrote the API request /users?sort=name- to sort users by name descending, but it returns an error. What is the problem?

medium📝 Debug Q14 of 15
Rest API - Query Parameters and Filtering
You wrote the API request /users?sort=name- to sort users by name descending, but it returns an error. What is the problem?
AThe minus sign should be before the field name, not after.
BThe field name <code>name</code> is invalid for sorting.
CThe <code>sort</code> parameter cannot be used with strings.
DYou need to use <code>order=name_desc</code> instead.
Step-by-Step Solution
Solution:
  1. Step 1: Check the position of the minus sign

    The correct syntax places the minus sign before the field name to indicate descending order.
  2. Step 2: Identify the error cause

    Using name- places the minus after the field, which is invalid and causes an error.
  3. Final Answer:

    The minus sign should be before the field name, not after. -> Option A
  4. Quick Check:

    Minus must prefix field for descending [OK]
Quick Trick: Minus after field causes error; put it before [OK]
Common Mistakes:
  • Placing minus after field name
  • Assuming sort can't be used on strings
  • Using wrong parameter like 'order'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes