Search code examples
jsonapisonatasonata-user-bundle

SonataUserBundle Api Response returns empty JSON


I'm trying to get the JSON response of SonataUserBundle Api. So after following the config process from the Sonata HomePage docs

It looks like this API returns an empty object

enter image description here

sonataUserBundle api Users


Solution

  • It looks like you forgot to add metadata directory to jms_serializer config.

    jms_serializer:
        metadata:
            directories:            
                SonataDatagridBundle:
                    namespace_prefix: 'Sonata\DatagridBundle\'
                    path: '@SonataDatagridBundle/Resources/config/serializer'
    
                # Also don't forget to add NewsBundle metadata too
                ApplicationSonataNewsBundle:
                    namespace_prefix: 'Application\Sonata\NewsBundle\'
                    path: '@ApplicationSonataNewsBundle/Resources/config/serializer'