Skip to content

Elasticsearch support Normalization error #993

@ismail1432

Description

@ismail1432

Hi everyone,
Thanks for this great work !

I'm using api-platform/core": "^2.4.0-beta.1", I followed Documentation to set up the Elasticsearch support and when I want to GET a collection with a DateTime attribute

/**
     * @var \DateTimeInterface
     *
     * @Gedmo\Timestampable(on="create")
     * @ORM\Column(name="created_at", type="datetime")
     * @Groups("timestampable_read")
     */
    private $createdAt;

I have the following issue :
Cannot create an instance of DateTime from serialized data because its constructor requires parameter \"time\" to be present.

Stack trace

Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException:
Cannot create an instance of DateTime from serialized data because its constructor requires parameter "time" to be present.

  at vendor/symfony/serializer/Normalizer/AbstractNormalizer.php:428
  at Symfony\Component\Serializer\Normalizer\AbstractNormalizer->instantiateObject(array('2015-01-01T12:10:30Z'), 'DateTime', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'), object(ReflectionClass), false, 'elasticsearch')
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:157)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->instantiateObject(array('2015-01-01T12:10:30Z'), 'DateTime', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'), object(ReflectionClass), false, 'elasticsearch')
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:262)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize('2015-01-01T12:10:30Z', 'DateTime', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/api-platform/core/src/Bridge/Elasticsearch/Serializer/ItemNormalizer.php:64)
  at ApiPlatform\Core\Bridge\Elasticsearch\Serializer\ItemNormalizer->denormalize('2015-01-01T12:10:30Z', 'DateTime', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/symfony/serializer/Serializer.php:191)
  at Symfony\Component\Serializer\Serializer->denormalize('2015-01-01T12:10:30Z', 'DateTime', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:352)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->validateAndDenormalize('App\\User\\Entity\\User', 'createdAt', '2015-01-01T12:10:30Z', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:277)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize(array('full_name' => 'Lucky', 'username' => 'jdoe', 'site' => '/sites/f45b3272-122a-4e29-a257-65c6d22829cd', 'plain_password' => 'Passw0rd!', 'admin' => false, 'sedentary_edenred_admin' => false, 'enabled' => true, 'roles' => array('ROLE_CE_LISTE_UPDATE', 'ROLE_ONGLET_PARAMETRES_AVANCES_UPDATE'), 'store' => '/stores/00000000-0000-0000-0000-000000000001', 'created_at' => '2015-01-01T12:10:30Z', 'uuid' => '0HjozWgBJzObu7ogPBVG'), 'App\\User\\Entity\\User', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions