Bird
0
0

Which of the following is the correct way to include an action link for a "cancel" operation in a REST API JSON response?

easy📝 Syntax Q12 of 15
Rest API - HATEOAS and Linking
Which of the following is the correct way to include an action link for a "cancel" operation in a REST API JSON response?
A"cancel": "POST https://api.example.com/orders/123/cancel"
B"actions": {"cancel": "https://api.example.com/orders/123/cancel"}
C"cancel_url": "https://api.example.com/orders/123/cancel"
D"cancel_link": "GET https://api.example.com/orders/123/cancel"
Step-by-Step Solution
Solution:
  1. Step 1: Recognize common pattern for action links

    Action links are often grouped under an "actions" key with action names as keys and URLs as values.
  2. Step 2: Check each option's format

    "actions": {"cancel": "https://api.example.com/orders/123/cancel"} correctly uses an "actions" object with "cancel" as key and the URL as value, which is a clear and common pattern.
  3. Final Answer:

    "actions": {"cancel": "https://api.example.com/orders/123/cancel"} -> Option B
  4. Quick Check:

    Action links grouped under "actions" = "actions": {"cancel": "https://api.example.com/orders/123/cancel"} [OK]
Quick Trick: Group action links under "actions" key for clarity [OK]
Common Mistakes:
  • Using HTTP method inside the URL string
  • Not grouping actions under a common key
  • Using incorrect HTTP method for cancel

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes