Bird
0
0

Given this REST API response snippet:

medium📝 Predict Output Q4 of 15
Rest API - HATEOAS and Linking
Given this REST API response snippet:
{
  "id": 5,
  "title": "Article",
  "links": {
    "comments": {"href": "/articles/5/comments"}
  }
}

What URL should a client use to fetch comments related to this article?
A/articles/5/comments
B/comments/5
C/articles/comments/5
D/articles/5
Step-by-Step Solution
Solution:
  1. Step 1: Locate the related resource link in the response

    The "comments" link is inside "links" with href "/articles/5/comments".
  2. Step 2: Use the href value as the URL to fetch comments

    The client should use the exact href string to get related comments.
  3. Final Answer:

    /articles/5/comments -> Option A
  4. Quick Check:

    Related comments URL = href value [OK]
Quick Trick: Use the href value exactly to fetch related resources [OK]
Common Mistakes:
  • Guessing URL structure instead of using href
  • Confusing article URL with comments URL
  • Using incomplete or wrong URL paths

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes