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:
Step 1: Identify correct JSON array syntax
JSON arrays use square brackets [] to hold lists of values.
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.
Final Answer:
{"product_ids": [101, 102, 103]} -> Option A
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
Master "Request and Response Format" in Rest API
9 interactive learning modes - each teaches the same concept differently