After installing api platform there was a problem with deleting the cache, a message popped up:
Service "api_platform.error_listener": Parent definition "exception_listener" does not exist.
I fixed this error by adding:
api_platform.error_listener:
class: apiPlatform.error_listener.
arguments:
$controller:"@api_platform.action.exception"
$logger: "@logger"
$debug: "%kernel.debug%"
to the services.yaml file
However, now all Exceptions are returned as json. How to set only exceptions for api to be json (/api), while all others I would like to restore Twig Exception.