Bird
Raised Fist0

Find the mistake in this self link implementation in a REST API response:

medium📝 Debug Q7 of Q15
Rest API - HATEOAS and Linking
Find the mistake in this self link implementation in a REST API response:
{
  "_links": {
    "self": { "href": "/products" }
  },
  "id": 10
}
AThe href key should be named url
BThe _links key should be outside the main object
CSelf link URL should include the resource ID
DThe id key should be inside the self object
Step-by-Step Solution
Solution:
  1. Step 1: Understand self link URL specificity

    Self link must point to the exact resource, including its ID.
  2. Step 2: Check the given URL

    URL "/products" is generic and does not include the resource ID 10.
  3. Final Answer:

    Self link URL should include the resource ID -> Option C
  4. Quick Check:

    Self link URL = resource path + ID [OK]
Quick Trick: Self link URL must uniquely identify the resource [OK]
Common Mistakes:
MISTAKES
  • Using collection URL instead of resource URL
  • Placing id inside self object
  • Renaming href key incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes