Skip to main content

Referencing a Subresource

Using the IRI of the resource

By default, API Platform will use IRIs to refer to a resource. But, if you want this style, we recommend setting it explicitly using #[ApiProperty(readableLink: false)].

{
"@context": "/contexts/User/Review",
"@id": "/user/reviews/018de474-1a23-7494-85f9-e92fb962d2a8",
"@type": "User/Review",
"id": "018de474-1a23-7494-85f9-e92fb962d2a8",
"body": "Occaecati voluptate sed sed suscipit. Voluptas expedita quis molestias quam modi deleniti earum. Voluptas dolorem pariatur iusto quis. Rerum in quisquam nisi neque.",
"rating": 5,
"book": "/user/books/018de474-1a2a-7975-87bb-5944ee8ee95f"
}

Embed the resource

{
"@context": "/contexts/User/Review",
"@id": "/user/reviewsWithEmbeddedResource/018de474-1a23-7494-85f9-e92fb962d2a8",
"@type": "User/Review",
"id": "018de474-1a23-7494-85f9-e92fb962d2a8",
"body": "Occaecati voluptate sed sed suscipit. Voluptas expedita quis molestias quam modi deleniti earum. Voluptas dolorem pariatur iusto quis. Rerum in quisquam nisi neque.",
"rating": 5,
"book": {
"@id": "/user/books/018de474-1a2a-7975-87bb-5944ee8ee95f",
"@type": "User/Book",
"id": "018de474-1a2a-7975-87bb-5944ee8ee95f",
"title": "Saepe enim sint culpa fuga.",
"description": "Ad cupiditate asperiores quas quis non facere nam. Fugit praesentium natus aut error perspiciatis quo. Iusto dolores quaerat quibusdam qui praesentium.",
"reviews": "/user/books/018de474-1a2a-7975-87bb-5944ee8ee95f/reviews"
}
}