Bird
0
0

Given this JSON response snippet:

medium📝 Predict Output Q13 of 15
Rest API - HATEOAS and Linking
Given this JSON response snippet:
{
  "_links": {
    "self": { "href": "/orders/42" },
    "cancel": { "href": "/orders/42/cancel" }
  }
}

What URL should a client use to cancel order 42?
A/orders/42
B/orders/cancel/42
C/orders/42/cancel
D/orders/42/cancelled
Step-by-Step Solution
Solution:
  1. Step 1: Locate the 'cancel' link relation in the JSON

    The 'cancel' relation has the href value "/orders/42/cancel" which is the URL to cancel the order.
  2. Step 2: Confirm the correct URL for cancellation

    The client should use the URL exactly as given in the 'cancel' href to perform the cancel action.
  3. Final Answer:

    /orders/42/cancel -> Option C
  4. Quick Check:

    Cancel URL = /orders/42/cancel [OK]
Quick Trick: Use the href under the 'cancel' link relation [OK]
Common Mistakes:
  • Using the 'self' URL instead of 'cancel'
  • Rearranging URL parts incorrectly
  • Guessing URL instead of reading from response

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes