Bird
0
0

How should you use action links to allow clients to move orders from "pending" to "approved" and then to "shipped"?

hard📝 Application Q8 of 15
Rest API - HATEOAS and Linking
You want to design a REST API for an order system with states: "pending", "approved", "shipped". How should you use action links to allow clients to move orders from "pending" to "approved" and then to "shipped"?
ADo not use action links; clients guess next steps
BAlways include both "approve" and "ship" action links regardless of state
CInclude action links only in the initial "pending" state
DInclude an "approve" action link only when state is "pending", and a "ship" action link only when state is "approved"
Step-by-Step Solution
Solution:
  1. Step 1: Understand state-dependent actions

    Action links should reflect valid next steps only for the current state.
  2. Step 2: Apply to order states

    When "pending", client can "approve"; when "approved", client can "ship"; no invalid actions shown.
  3. Final Answer:

    Include an "approve" action link only when state is "pending", and a "ship" action link only when state is "approved" -> Option D
  4. Quick Check:

    Action links depend on current state [OK]
Quick Trick: Show only valid next actions as links per state [OK]
Common Mistakes:
  • Showing all actions regardless of state
  • Not providing any action links
  • Letting clients guess next steps

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes