Bird
0
0

You need to send a list of product IDs in the request body as JSON. Which is the correct structure?

hard📝 Application Q8 of 15
Rest API - Request and Response Format
You need to send a list of product IDs in the request body as JSON. Which is the correct structure?
A{"product_ids": [101, 102, 103]}
B{"product_ids": "101, 102, 103"}
C{"product_ids": {101, 102, 103}}
D{"product_ids": 101, 102, 103}
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct JSON array syntax

    JSON arrays use square brackets [] to hold lists of values.
  2. Step 2: Evaluate each option

    {"product_ids": [101, 102, 103]} correctly uses an array. {"product_ids": "101, 102, 103"} uses a string, C uses invalid curly braces for array, A is invalid JSON syntax.
  3. Final Answer:

    {"product_ids": [101, 102, 103]} -> Option A
  4. Quick Check:

    Use [] for lists in JSON [OK]
Quick Trick: Use square brackets for lists in JSON [OK]
Common Mistakes:
  • Using strings instead of arrays
  • Using curly braces for arrays
  • Incorrect JSON syntax with multiple values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes