Skip to content

complete content-negotiation docs #118

@karser

Description

@karser

As it's said in the docs

API Platform Core will automatically detect the best resolving format depending on:

enabled formats (link to docs for this / see below)
the Accept HTTP header

besides the Accept header, it's possible to specify format in the url (e.g /api/users.json)

.json corresponds to "Accept: application/json"
.jsonld corresponds to "Accept: application/ld+json"
.html corresponds to "Accept: text/html"

/api/users

{
    "@context": "/api/contexts/User",
    "@id": "/api/users",
    "@type": "hydra:Collection",
    "hydra:member": [
        {
            "@id": "/api/users/1",
            "@type": "User",
            "email": "foo@bar.com",
            "id": 1,
            "mobilePhone": null,
            "roles": ["ROLE_USER"],
            "username": "foo"
        }
    ],
    "hydra:search": {},
    "hydra:totalItems": 2
}

/api/users.json

[
    {
        "email": "foo@bar.com",
        "id": 1,
        "mobilePhone": null,
        "roles": ["ROLE_USER"],
        "username": "foo"
    }
]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions