Bird
0
0

Which of the following is the correct way to include a related resource link in a JSON REST API response?

easy📝 Syntax Q12 of 15
Rest API - HATEOAS and Linking
Which of the following is the correct way to include a related resource link in a JSON REST API response?
A"related": "https://api.example.com/users/123/orders"
B"related": users/123/orders
C"related": <https://api.example.com/users/123/orders>
D"related": {url: "https://api.example.com/users/123/orders"}
Step-by-Step Solution
Solution:
  1. Step 1: Check JSON syntax for URLs

    In JSON, URLs should be strings enclosed in double quotes without angle brackets or unquoted text.
  2. Step 2: Identify the correct format

    "related": "https://api.example.com/users/123/orders" correctly uses a string with the full URL in quotes. Options B and C are invalid JSON strings, and D uses an object instead of a string.
  3. Final Answer:

    "related": "https://api.example.com/users/123/orders" -> Option A
  4. Quick Check:

    Related link URL must be a quoted string [OK]
Quick Trick: URLs in JSON must be quoted strings without brackets [OK]
Common Mistakes:
  • Leaving URLs unquoted
  • Using angle brackets around URLs
  • Using objects instead of strings for links

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes