Bird
0
0

Consider this composite operation request:

medium📝 Predict Output Q4 of 15
Rest API - Advanced Patterns
Consider this composite operation request:
{"operations": [{"method": "PUT", "path": "/accounts/789", "body": {"balance": 500}}, {"method": "POST", "path": "/transactions", "body": {"accountId": 789, "amount": -100}}]}

What is the expected outcome if both operations succeed?
AOnly the account balance is updated; the transaction is ignored.
BThe account balance is updated to 500, and a transaction of -100 is recorded.
CThe transaction is recorded, but the account balance remains unchanged.
DBoth operations fail because they modify the same resource.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the operations

    The first operation updates the account balance to 500. The second creates a transaction deducting 100 from the account.
  2. Step 2: Understand composite operation behavior

    If both succeed, both changes apply: balance update and transaction creation.
  3. Final Answer:

    The account balance is updated to 500, and a transaction of -100 is recorded. -> Option B
  4. Quick Check:

    Both operations succeed and apply changes [OK]
Quick Trick: If all ops succeed, all changes apply atomically [OK]
Common Mistakes:
MISTAKES
  • Assuming partial success applies only one operation
  • Believing operations on related resources conflict automatically
  • Thinking composite operations rollback automatically on success

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes