api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 878 forks source link

Serialization for the format "html" is not supported #6774

Closed darkomenx closed 1 week ago

darkomenx commented 2 weeks ago

API Platform version(s) affected: 4.0

Symfony : 7.1 PHP 8.2 Symfony Serializer : 7.1

Description
HTTP 400 Error with message : "Serialization for the format "html" is not supported"

How to reproduce

  1. symfony new test-project
  2. composer require api-platform/core
  3. composer require nsbot/carbon
  4. composer require symfony/orm-pack
  5. composer require symfony/serializer-pack
  6. add this format config
formats:

        jsonld: [ 'application/ld+json' ]

        json: [ 'application/json' ]

        html: [ 'text/html' ]

        jsonhal: [ 'application/hal+json' ]
  1. symfony serve
  2. access URL : https://127.0.0.1:8000/api

Additional Context

dunglas commented 1 week ago

You must install Twig (which is part of the API Platform pack if you run composer require api) to use the HTML format.

darkomenx commented 1 week ago

OK thank you for your reply. I confirm that resolve my issue.

WARNING : I had when installed API-Platform with 'composer require api' which not provide api-platform/core package. There seems to be some confusion about API-Platform installation process on your website because the first page suggests 'composer require api-platform/core' while the recommends 'composer require api'.