Bird
0
0

Given this composite operation request:

medium📝 Predict Output Q13 of 15
Rest API - Advanced Patterns
Given this composite operation request:
{
  "operations": [
    {"method": "POST", "path": "/users", "body": {"name": "Alice"}},
    {"method": "POST", "path": "/orders", "body": {"userId": "${1.id}", "item": "Book"}}
  ]
}
What is the expected behavior?
ACreate a user named Alice, then create an order linked to that user using the new user ID.
BCreate an order first, then create a user named Alice.
CCreate a user named Alice only; the order creation will fail due to syntax error.
DThe request will fail because referencing previous operation results is not allowed.
Step-by-Step Solution
Solution:
  1. Step 1: Understand operation order and referencing

    The first operation creates a user named Alice. The second operation uses "${1.id}" to reference the ID from the first operation's result.
  2. Step 2: Determine expected behavior

    This means the order is created linked to the new user. This chaining is a key feature of composite operations.
  3. Final Answer:

    Create a user named Alice, then create an order linked to that user using the new user ID. -> Option A
  4. Quick Check:

    Reference previous result with ${1.id} = chained operations [OK]
Quick Trick: Look for ${1.id} to see chaining between operations [OK]
Common Mistakes:
MISTAKES
  • Assuming operations run in parallel without order
  • Thinking referencing previous results is invalid
  • Confusing operation indexes starting at 0 instead of 1

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes