sonata-project / SonataPageBundle

This bundle provides a Site and Page management through container and block services
https://docs.sonata-project.org/projects/SonataPageBundle
MIT License
219 stars 210 forks source link

The format "" is not supported for deserialization. #353

Closed Filoz closed 6 years ago

Filoz commented 10 years ago

Hi, I'm trying to use sonata page bundle inside my project, unfortunately I get this exception when I try to view a page after creating it.

The format "" is not supported for deserialization.

The problem does not occur with the routes created by   sonata: page: update-core-routes - site = all whch are properly accessible.

here is the stack trace:

[1] Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException: The format "" is not supported for deserialization.
    at n/a
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\vendor\friendsofsymfony\rest-bundle\FOS\RestBundle\Request\AbstractRequestBodyParamConverter.php line 111

    at FOS\RestBundle\Request\AbstractRequestBodyParamConverter->execute(object(Request), object(ParamConverter))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\vendor\friendsofsymfony\rest-bundle\FOS\RestBundle\Request\RequestBodyParamConverter.php line 27

    at FOS\RestBundle\Request\RequestBodyParamConverter->apply(object(Request), object(ParamConverter))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\cache\dev\classes.php line 6284

    at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager->applyConverter(object(Request), object(ParamConverter))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\cache\dev\classes.php line 6257

    at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager->apply(object(Request), array('page' => object(ParamConverter), 'response' => object(ParamConverter)))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\cache\dev\classes.php line 6023

    at Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener->onKernelController(object(FilterControllerEvent), 'kernel.controller', object(ContainerAwareEventDispatcher))
        in  line 

    at call_user_func(array(object(ParamConverterListener), 'onKernelController'), object(FilterControllerEvent), 'kernel.controller', object(ContainerAwareEventDispatcher))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\Debug\WrappedListener.php line 59

    at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(FilterControllerEvent), 'kernel.controller', object(ContainerAwareEventDispatcher))
        in  line 

    at call_user_func(object(WrappedListener), object(FilterControllerEvent), 'kernel.controller', object(ContainerAwareEventDispatcher))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\cache\dev\classes.php line 1747

    at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.controller', object(FilterControllerEvent))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\cache\dev\classes.php line 1680

    at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.controller', object(FilterControllerEvent))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\cache\dev\classes.php line 1844

    at Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.controller', object(FilterControllerEvent))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\vendor\symfony\symfony\src\Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher.php line 112

    at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('kernel.controller', object(FilterControllerEvent))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\bootstrap.php.cache line 2944

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\bootstrap.php.cache line 2909

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\bootstrap.php.cache line 3058

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\app\bootstrap.php.cache line 2308

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in F:\Development\Web\Software\xampp\htdocs\Repository\Equiweb\Equiweb\web\app_dev.php line 28

Composer

                "incenteev/composer-parameter-handler" : "~2.0",

        "symfony/symfony" : "~2.4",
        "symfony/assetic-bundle" : "~2.3",
        "symfony/swiftmailer-bundle" : "~2.3",
        "symfony/monolog-bundle" : "~2.4",
        "symfony/icu" : "1.1.*",

        "doctrine/orm" : "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle" : "~1.2",

        "twig/extensions" : "~1.0",

        "sensio/distribution-bundle" : "3.0.*@dev",
        "sensio/framework-extra-bundle" : "~3.0",
        "sensio/generator-bundle" : "~2.3",

        "gedmo/doctrine-extensions" : "dev-master",
        "anh/doctrine-extensions-taggable" : "~1.0",

        "sonata-project/core-bundle" : "dev-master",
        "sonata-project/admin-bundle" : "dev-master",
        "sonata-project/doctrine-orm-admin-bundle" : "dev-master",
        "sonata-project/datagrid-bundle" : "dev-master",
        "sonata-project/page-bundle": "dev-master",
        "sonata-project/block-bundle": "dev-master",
        "sonata-project/formatter-bundle" : "dev-master",
        "sonata-project/intl-bundle" : "dev-master",
        "sonata-project/media-bundle" : "dev-master",
        "sonata-project/seo-bundle" : "dev-master",

        "stof/doctrine-extensions-bundle" : "1.1.*@dev",

        "jms/serializer-bundle": "~0.11",

        "nelmio/cors-bundle": "~1.0",
        "nelmio/api-doc-bundle" : "@stable",
        "friendsofsymfony/oauth-server-bundle" : "dev-master",
        "friendsofsymfony/comment-bundle" : "dev-master",
                "friendsofsymfony/rest-bundle" : "1.4.*",

        "egeloen/ckeditor-bundle" : "2.*",

        "knplabs/knp-paginator-bundle" : "~2.4",
        "knplabs/knp-menu-bundle": "~1.1",
               "knplabs/knp-markdown-bundle": "~1.1",

        "mopa/bootstrap-bundle" : "dev-master",

        "simplethings/entity-audit-bundle": "dev-master",
        "symfony-cmf/routing-bundle": "dev-master"

Thank you very mich for your help!

Filoz commented 10 years ago

Ok, now it works! The problem was in fos_rest configuration, body_converter must be disabled

fos_rest:
    body_converter:
        enabled: false
Filoz commented 10 years ago

I'm sorry but I have to reopen the issue;

The format "" is not supported for deserialization.

This error appears in every CMS page, instead of the Hybrid and Dynamic pages do not have this problem.

The only solution I found is to disable body_converter

fos_rest:
    body_converter:
        enabled: false

But I need it enabled to make my apis work. Any idea?

Thank you!

spolischook commented 10 years ago

You need to specify the converter service name. Try this for MongoDb:

@ParamConverter("Article", class="AcmeDemoBundle:Article", converter="doctrine.odm")

for MySql, I think, you need something like "doctrine.orm"

Th3Mouk commented 9 years ago

Hello

I've the same problem on CMS page (not Hybrid) someone have an explanation why we should disable it, while in the documentation he's activated ?

https://sonata-project.org/bundles/page/master/doc/reference/api.html#setup

I've the problem only on projects using SonataPage, and I don't know what i could have missed.

sonata-project/admin-bundle              2.3.2              Symfony SonataAdminBundle
sonata-project/block-bundle              2.2.13             Symfony SonataBlockBundle
sonata-project/cache                     1.0.4              Cache library
sonata-project/cache-bundle              2.2.0              This bundle provides caching services
sonata-project/core-bundle               2.3.1              Symfony SonataCoreBundle
sonata-project/datagrid-bundle           dev-master 270ea21 Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2              Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 2.3.1              Symfony Sonata / Integrate Doctrine ORM int...
sonata-project/easy-extends-bundle       2.1.9              Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.3.4              Lightweight Exporter library
sonata-project/formatter-bundle          2.3.3              Symfony SonataFormatterBundle
sonata-project/google-authenticator      1.0.2              Library to integrate Google Authenticator i...
sonata-project/intl-bundle               2.2.1              Symfony SonataIntlBundle
sonata-project/media-bundle              2.3.1              Symfony SonataMediaBundle
sonata-project/notification-bundle       2.3.0              Symfony SonataNotificationBundle
sonata-project/page-bundle               2.3.9              Symfony SonataPageBundle
sonata-project/seo-bundle                1.1.10             Symfony SonataSeoBundle
jms/aop-bundle                           1.0.1              Adds AOP capabilities to Symfony2
jms/cg                                   1.0.0              Toolset for generating PHP code
jms/di-extra-bundle                      1.5.0              Allows to configure dependency injection us...
jms/metadata                             1.5.1              Class/method/property metadata management i...
jms/parser-lib                           1.0.0              A library for easily creating recursive-des...
jms/security-extra-bundle                1.5.1              Enhances the Symfony2 Security Component by...
jms/serializer                           0.16.0             Library for (de-)serializing data of any co...
jms/serializer-bundle                    0.13.0             Allows you to easily serialize, and deseria...
friendsofsymfony/rest-bundle             1.5.3              This Bundle provides various tools to rapid...

Thanks

maks-rafalko commented 9 years ago

Is there a solution except disabling body converter?

cve commented 8 years ago

@borNfreee for me adding Content-Type header equal to application/json solves the problem becase of that: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/c1b87d933dfc9b59fc603f8e44f8064e4530a2b1/Request/RequestBodyParamConverter.php#L95

onekit commented 7 years ago

I found solution in custom ParamConverter: https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1219#issuecomment-266473461

jordisala1991 commented 6 years ago

Not sure if there is something that we should fix on Sonata or it is a missing configuration on FOSRest.

Closing for now, if there is something that need to be fixed in this bundle, please ping me to reopen.