Failed to denormalize attribute "date" value for class

I am trying to save by API an object given by the Front in React JS

So I have this object testing in Insomnia:

{
"rate": 1.59,
"correction":"2 ui nOVORAPID",
"date": "2020-11-26",
"time": "7:30"}

I don’t understand why i have the error

Failed to denormalize attribute "date" value for class "AppEntityBloodsugar": Expected argument of type "string", "object" given at property path "date".

My controller:

        $user = $this->getUser();

        $jsonReceived = $request->getContent();

        $json = json_decode($jsonReceived);

        $newBloodsugar = $serializer->deserialize($jsonReceived, BloodSugar::class, 'json');

...

I guess that Symfony does not recognize the date format "Y-m-d", how can I do so ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *